当前位置: 首页>>代码示例>>PHP>>正文


PHP Guard::once方法代码示例

本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard::once方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::once方法的具体用法?PHP Guard::once怎么用?PHP Guard::once使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Illuminate\Contracts\Auth\Guard的用法示例。


在下文中一共展示了Guard::once方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authorize

 /**
  * Authorize the user
  *
  * @param ResponseFactory $response
  * @return array|\Illuminate\Http\Response
  */
 public function authorize(ResponseFactory $response)
 {
     $credentials = array_merge($this->request->only(['username', 'password']), ['status' => 'active']);
     if (!$this->auth->once($credentials)) {
         return $response->make('Invalid credentials', 401);
     }
     /*
                     if (!$this->isAuthorized($userRoles)) {
                         return $response->make('Unauthorized user', 401);
                     }*/
     return ['token' => $this->getUserToken($this->auth->user())];
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:18,代码来源:AuthenticationController.php

示例2: verify

 /**
  * Check credentials for oauth password grant
  * @param  string $username
  * @param  sting $password
  * @return boolean|int
  */
 public function verify($username, $password)
 {
     $credentials = compact('password');
     if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
         $credentials['email'] = $username;
     } else {
         $credentials['username'] = $username;
     }
     $credentials['active'] = 1;
     if ($this->auth->once($credentials)) {
         return $this->auth->id();
     }
     return false;
 }
开发者ID:ruysu,项目名称:laravel-core,代码行数:20,代码来源:OAuthPasswordGrantVerifier.php

示例3: postLogin

 /**
  * Perform login attempt
  * @param  AuthRequestInterface $request
  * @param  Guard                $auth
  * @return Illuminate\Http\Response
  */
 public function postLogin(AuthRequestInterface $request, Guard $auth)
 {
     if (($throttles = $this->throttlesLogins()) && $this->hasTooManyLoginAttempts($request)) {
         return $this->sendLockoutResponse($request);
     }
     $credentials = $request->only('password');
     $username = $request->get('username');
     if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
         $credentials['email'] = $username;
     } else {
         $credentials['username'] = $username;
     }
     if ($auth->once($credentials)) {
         $user = $auth->user();
         if ($throttles) {
             $this->clearLoginAttempts($request);
         }
         if (!$user->active) {
             return $this->handleUserIsNotActive($request, $user);
         }
         $this->authenticateUser($auth, $user);
         return $this->handleUserWasAuthenticated($request, $user);
     }
     if ($throttles) {
         $this->incrementLoginAttempts($request);
     }
     return $this->handleUserWasNotAuthenticated($request);
 }
开发者ID:ruysu,项目名称:laravel-core,代码行数:34,代码来源:AuthenticatesUsers.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  * @throws \App\Exceptions\InvalidCredentialsException
  * @throws \App\Exceptions\NoAuthenticationException
  */
 public function handle($request, Closure $next)
 {
     if (empty($request->header('Authorization'))) {
         throw new \App\Exceptions\NoAuthenticationException();
     }
     $header = $request->headers->get('Authorization');
     if (starts_with(strtolower($header), 'bearer')) {
         //If token is passed (to refresh)
         /** @var User $user */
         $user = \JWTAuth::setRequest($request)->parseToken()->authenticate();
         \JWTAuth::invalidate();
         //invalidate the old token
         $this->auth->setUser($user);
     } else {
         //if credentials are passed
         $credentials = ['email' => $request->getUser(), 'password' => $request->getPassword()];
         $this->auth->once($credentials);
     }
     $isAuthenticated = $this->auth->check();
     if (!$isAuthenticated) {
         throw new \App\Exceptions\InvalidCredentialsException();
     }
     return $next($request);
 }
开发者ID:LeeKevin,项目名称:laravel-api,代码行数:33,代码来源:Authenticate.php

示例5: postLogin

 /**
  * Handle a login request to the application.
  *
  * @param AuthRequest $request
  * @return \Illuminate\Http\Response
  */
 public function postLogin(AuthRequest $request)
 {
     $throttles = in_array(ThrottlesLogins::class, class_uses_recursive(get_class($this)));
     if ($throttles && $this->hasTooManyLoginAttempts($request)) {
         return $this->respondThrottled($request);
     }
     if (!$this->auth->once($request->only('email', 'password'))) {
         if ($throttles) {
             $this->incrementLoginAttempts($request);
         }
         return $this->respondLoginFail($request);
     }
     $user = $this->auth->getUser();
     if (!$user->activated) {
         $this->auth->logout();
         return $this->respondNotActivated($request, $user->activation_code);
     }
     $this->auth->loginUsingId($user->id, $request->has('remember'));
     if ($throttles) {
         $this->clearLoginAttempts($request);
     }
     event('UserHasLoggedIn', [$this->auth->user()]);
     return $this->respondLoginSuccess($request, $user);
 }
开发者ID:valdinei,项目名称:rest,代码行数:30,代码来源:SessionController.php

示例6: byCredentials

 /**
  * Check a user's credentials.
  *
  * @param  array $credentials
  *
  * @return bool
  */
 public function byCredentials(array $credentials)
 {
     return $this->auth->once($credentials);
 }
开发者ID:rchoffardet,项目名称:api-guard,代码行数:11,代码来源:Illuminate.php


注:本文中的Illuminate\Contracts\Auth\Guard::once方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。