本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard类的典型用法代码示例。如果您正苦于以下问题:PHP Guard类的具体用法?PHP Guard怎么用?PHP Guard使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Guard类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(UsersRepo $usersRepo, Guard $guard)
{
$this->usersRepo = $usersRepo;
$this->current_user = $guard->user();
$this->middleware('CMSAuthenticate');
view()->share('user_types', getUserTypesList());
}
示例2: postLogin
/**
* 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'));
}
示例3: handle
/**
* 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);
}
示例4: handle
/**
* 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);
}
示例5: handle
/**
* 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);
}
示例6: handle
/**
* 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);
}
示例7: handle
/**
* 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);
}
示例8: handle
/**
* 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);
}
示例9: handle
/**
* 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);
}
示例10: handle
/**
* 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);
}
示例11: handle
/**
* 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);
}
示例12: handle
/**
* 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);
}
示例13: handle
/**
* 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);
}
示例14: handle
/**
* 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);
}
示例15: handle
/**
* 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);
}