Пример #1
0
 /**
  * Authenticate a user via the id
  *
  * @param  mixed  $id
  *
  * @return boolean
  */
 public function byId($id)
 {
     try {
         return $this->auth->onceUsingId($id);
     } catch (Exception $e) {
         return false;
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($apiToken = $request->header('X-Cachet-Token')) {
             try {
                 $this->auth->onceUsingId(User::findByApiToken($apiToken)->id);
             } catch (ModelNotFoundException $e) {
                 //
             }
         }
     }
     return $next($request);
 }
Пример #3
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $scopesString = null)
 {
     $scopes = [];
     if (!is_null($scopesString)) {
         $scopes = explode('+', $scopesString);
     }
     try {
         $this->authorizer->validateAccessToken($this->httpHeadersOnly);
         $this->validateScopes($scopes);
         if ($this->authorizer->getResourceOwnerType() == 'user') {
             $this->auth->onceUsingId($this->authorizer->getResourceOwnerId());
         }
     } catch (Exception $e) {
     }
     return $next($request);
 }
Пример #4
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  * @param bool                     $required
  *
  * @return mixed
  */
 public function handle($request, Closure $next, $required = false)
 {
     if ($this->auth->guest()) {
         if ($apiToken = $request->header('X-Cachet-Token')) {
             try {
                 $this->auth->onceUsingId(User::findByApiToken($apiToken)->id);
             } catch (ModelNotFoundException $e) {
                 if ($required) {
                     throw new HttpException(401);
                 }
             }
         } elseif ($required) {
             throw new HttpException(401);
         }
     }
     return $next($request);
 }
Пример #5
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->guest()) {
         if ($apiToken = $request->header('X-Gitamin-Token')) {
             try {
                 $this->auth->onceUsingId(User::findByApiToken($apiToken)->id);
             } catch (ModelNotFoundException $e) {
                 throw new HttpException(401);
             }
         } elseif ($request->getUser()) {
             if ($this->auth->onceBasic() !== null) {
                 throw new HttpException(401);
             }
         } else {
             throw new HttpException(401);
         }
     }
     return $next($request);
 }
Пример #6
0
 /**
  * Authenticate a user via the id.
  *
  * @param  mixed $id
  *
  * @return bool
  */
 public function byId($id)
 {
     return $this->auth->onceUsingId($id);
 }