作者:rubenalternativ
项目:simple-cm
public function __construct(UsersRepo $usersRepo, Guard $guard)
{
$this->usersRepo = $usersRepo;
$this->current_user = $guard->user();
$this->middleware('CMSAuthenticate');
view()->share('user_types', getUserTypesList());
}
作者:thaid
项目:CM
/**
* Handle a login request to the application.
*
* @param App\Http\Requests\LoginRequest $request
* @param App\Services\MaxValueDelay $maxValueDelay
* @param Guard $auth
* @return Response
*/
public function postLogin(LoginRequest $request, Guard $auth)
{
$logValue = $request->input('log');
$logAccess = filter_var($logValue, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
$throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
if ($throttles && $this->hasTooManyLoginAttempts($request)) {
return redirect('/auth/login')->with('error', trans('front/login.maxattempt'))->withInput($request->only('log'));
}
$credentials = [$logAccess => $logValue, 'password' => $request->input('password')];
if (!$auth->validate($credentials)) {
if ($throttles) {
$this->incrementLoginAttempts($request);
}
return redirect('/auth/login')->with('error', trans('front/login.credentials'))->withInput($request->only('log'));
}
$user = $auth->getLastAttempted();
if ($user->confirmed) {
if ($throttles) {
$this->clearLoginAttempts($request);
}
$auth->login($user, $request->has('memory'));
if ($request->session()->has('user_id')) {
$request->session()->forget('user_id');
}
return redirect('/');
}
$request->session()->put('user_id', $user->id);
return redirect('/auth/login')->with('error', trans('front/verify.again'));
}
作者:bitlle
项目:nov
/**
* @param Guard $auth
* @param Roles $roles
* @return bool
*/
public function authorize(Guard $auth, Roles $roles)
{
if ($auth->check() && $roles->isAdmin()) {
return true;
}
return false;
}
作者:lialosi
项目:amaoto-cor
public function doCreateAlbum(Guard $guard, Request $request)
{
if ($guard->guest()) {
throw new AppException(AppException::NEED_SIGN_IN);
}
$musics = $request->get('musics');
$coverImageId = $request->get('cover_image_id');
$title = $request->get('title');
$artist = $request->get('artist');
$year = $request->get('year');
$genre = $request->get('genre');
$album = new Album();
$album->title = $title;
$album->artist = $artist;
$album->year = $year;
$album->genre = $genre;
$album->coverImage()->associate($coverImageId);
$album->user()->associate($guard->id());
$album->save();
foreach ($musics as $musicId) {
/** @var Music $music */
$music = Music::where('id', $musicId)->first();
if (!$music) {
continue;
}
$album->musics()->attach($musicId);
if (!$music->coverImage) {
$music->coverImage()->associate($album->coverImage);
$music->save();
}
}
return $this->buildResponse(trans('api.album.create.success'), Tools::toArray($album));
}
作者:Cecicecicec
项目:MySJSU-Class-Registratio
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
return redirect('SiteController@index');
}
return $next($request);
}
作者:xiaobail
项目:Gitami
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
throw new HttpException(401);
}
return $next($request);
}
作者:pcmquizo
项目:127-Overflo
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
//return redirect('/user/dashboard');
}
return $next($request);
}
作者:lovet
项目:toil
/**
* Handle an incoming request.
*
* @param Request $request The current request.
* @param Closure $next The handler to receive the request.
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
if ($this->auth->check()) {
return Redirect::route('home');
}
return $next($request);
}
作者:JFSolorzan
项目:Acorde
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
return \Redirect::back();
}
return $next($request);
}
作者:suitmedi
项目:suitcod
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->auth->user()->isAdmin()) {
return response('Unauthorized.', 401);
}
return $next($request);
}
作者:nich-mctish
项目:laravel-framewor
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->auth->check() || !$this->auth->user()->hasRole($this->role)) {
App::abort(401);
}
return $next($request);
}
作者:mcclainconcept
项目:role
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param int|string $permission
* @return mixed
* @throws \Bican\Roles\Exceptions\PermissionDeniedException
*/
public function handle($request, Closure $next, $permission)
{
if ($this->auth->check() && $this->auth->user()->may($permission)) {
return $next($request);
}
throw new PermissionDeniedException($permission);
}
作者:asarmient
项目:CPHo
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->auth->user()) {
return redirect('/');
}
return $next($request);
}
作者:guduchang
项目:Cache
/**
* We're verifying that the current user is logged in to Cachet and is an admin level.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!$this->auth->check() || $this->auth->check() && !$this->auth->user()->isAdmin) {
throw new HttpException(401);
}
return $next($request);
}
作者:eunio
项目:role
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param int $level
* @return mixed
* @throws \Bican\Roles\Exceptions\LevelDeniedException
*/
public function handle($request, Closure $next, $level)
{
if ($this->auth->check() && $this->auth->user()->level() >= $level) {
return $next($request);
}
throw new LevelDeniedException($level);
}
作者:dipeshrija
项目:blogcm
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
return redirect(route('backend.dashboard'));
}
return $next($request);
}
作者:rob-me
项目:weddinge
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check()) {
return redirect()->route('event.index');
}
return $next($request);
}
作者:ehomeu
项目:ehom
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (is_null($this->auth->user()->household)) {
return redirect(route('household.create'));
}
return $next($request);
}
作者:jeremytubbs-deprecate
项目:L51-Start-Her
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->check() && !$request->user()->hasGroup('admin')) {
return redirect('/');
}
return $next($request);
}
作者:php-sof
项目:laravel-comment
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->auth->guest()) {
return response()->json(null, 401);
}
return $next($request);
}