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


PHP Request::getUser方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (env('APP_ENV') != 'local' && !in_array($request->ip(), $this->allowIps)) {
         if (empty($request->getUser()) || empty($request->getPassword()) || $request->getUser() !== $this->credentials['id'] || $request->getPassword() !== $this->credentials['password']) {
             return $this->auth->basic();
         }
     }
     return $next($request);
 }
开发者ID:mint-soft-com,项目名称:xpressengine,代码行数:16,代码来源:AuthenticateInside.php

示例2: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->getUser() != env('AUTH_BASIC_USER') || $request->getPassword() != env('AUTH_BASIC_PASS')) {
         $headers = ['WWW-Authenticate' => 'Basic'];
         return response('Invalid credentials.', 401, $headers);
     }
     return $next($request);
 }
开发者ID:jumilla,项目名称:laravel5-sample-todo,代码行数:15,代码来源:BasicAuth.php

示例3: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $valid = $request->getUser() == env('BASIC_USERNAME') && $request->getPassword() == env('BASIC_PASSWORD');
     if ($valid) {
         return $next($request);
     }
     $headers = ['WWW-Authenticate' => 'Basic'];
     return new Response('Invalid credentials.', 401, $headers);
 }
开发者ID:javanlabs,项目名称:tender,代码行数:16,代码来源:CustomBasicAuth.php

示例4: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // check current environment
     if (App::environment() !== "development" && App::environment() !== "testing") {
         // check given credentials
         if ($request->getUser() !== config('app.api_user') || $request->getPassword() !== config('app.api_password')) {
             return response()->json(['error' => 'Invalid credentials.'], 401)->header('WWW-Authenticate', 'Basic');
         }
     }
     return $next($request);
 }
开发者ID:MyGrades,项目名称:mygrades-server,代码行数:18,代码来源:BasicAuthMiddleware.php

示例5: login

 /**
  * Log in a user.
  *
  * @param Request $request
  *
  * @return ApiResponse
  */
 public function login(Request $request)
 {
     $credentials = ['email' => $request->getUser(), 'password' => $request->getPassword()];
     if (!($token = $this->attemptLogin($credentials))) {
         // Check to see if the user has recently requested to change their email and try to log in using it
         if ($oldEmail = User::findCurrentEmail($credentials['email'])) {
             $credentials['email'] = $oldEmail;
             if (!($token = $this->attemptLogin($credentials))) {
                 throw new UnauthorizedException('Credentials failed.');
             }
         } else {
             throw new UnauthorizedException('Credentials failed.');
         }
     }
     return $this->getResponse()->transformer($this->transformer)->item($token);
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:23,代码来源:AuthController.php

示例6: 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()) {
         if ($apiToken = $request->header('X-Gitamin-Token')) {
             try {
                 $this->auth->onceUsingId(User::findByApiToken($apiToken)->id);
             } catch (ModelNotFoundException $e) {
                 //
             }
         } elseif ($request->getUser()) {
             if ($this->auth->onceBasic() !== null) {
                 //
             }
         }
     }
     return $next($request);
 }
开发者ID:xiaobailc,项目名称:Gitamin,代码行数:25,代码来源:ApiOptionalAuthenticate.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // Load configuration
     $veryBasicAuthUser = config('very_basic_auth.user');
     $veryBasicAuthPass = config('very_basic_auth.password');
     $veryBasicAuthEnvs = config('very_basic_auth.envs');
     $veryBasicAuthMsg = config('very_basic_auth.error_message');
     $veryBasicAuthView = config('very_basic_auth.error_view');
     // Check if middleware is in use in current environment
     if (in_array(app()->environment(), $veryBasicAuthEnvs)) {
         if ($request->getUser() != $veryBasicAuthUser || $request->getPassword() != $veryBasicAuthPass) {
             $header = ['WWW-Authenticate' => 'Basic'];
             // If view is available
             if ($veryBasicAuthView) {
                 return response()->view($veryBasicAuthView, [], 401)->withHeaders($header);
             }
             // Else return default message
             return response($veryBasicAuthMsg, 401, $header);
         }
     }
     return $next($request);
 }
开发者ID:olssonm,项目名称:l5-very-basic-auth,代码行数:29,代码来源:VeryBasicAuth.php

示例8: getUser

 /**
  * Returns the user.
  *
  * @return string|null 
  * @static 
  */
 public static function getUser()
 {
     //Method inherited from \Symfony\Component\HttpFoundation\Request
     return \Illuminate\Http\Request::getUser();
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例9: getBasicCredentials

 /**
  * Get the credential array for a HTTP Basic request.
  *
  * @param \Illuminate\Http\Request $request
  * @param string                   $field
  *
  * @return array
  */
 protected function getBasicCredentials(Request $request, $field)
 {
     return [$field => $request->getUser(), 'password' => $request->getPassword()];
 }
开发者ID:arubacao,项目名称:http-basic-auth-guard,代码行数:12,代码来源:BasicGuard.php

示例10: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param string|null $user
  *
  * @return mixed
  */
 public function handle($request, Closure $next, string $user = null)
 {
     $this->shield->verify($request->getUser(), $request->getPassword(), $user);
     return $next($request);
 }
开发者ID:vinkla,项目名称:laravel-shield,代码行数:14,代码来源:ShieldMiddleware.php


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