當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。