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


PHP JWTAuth::authenticate方法代码示例

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


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

示例1: login

 public function login($data)
 {
     $credentials = ['email' => strtolower(array_get($data, 'email')), 'password' => array_get($data, 'password')];
     if (!($token = $this->returnToken($credentials))) {
         throw new Exception('No user with that email and password combination exists in our database.', 500);
     }
     return [JWTAuth::authenticate($token), $token];
 }
开发者ID:ajoelp,项目名称:portfolio-2015,代码行数:8,代码来源:AuthRepository.php

示例2: authenticate

 /**
  * Authenticate the user using JWT.
  *
  * @param AuthJwtRequest $request
  * @return $this|\Illuminate\Http\JsonResponse
  */
 public function authenticate(AuthJwtRequest $request)
 {
     $credentials = $request->only(['email', 'password']);
     // Attempt to verify the credentials and create a token for the user
     if (!($token = JWTAuth::attempt($credentials))) {
         $response = $this->response->error(ResponseCode::UNAUTHORIZED, trans('texts.invalid_credentials'));
     } else {
         $data = ['token' => $token, 'user' => JWTAuth::authenticate($token)];
         $response = $this->response->ok($data);
     }
     return $response;
 }
开发者ID:Virgeto,项目名称:GG-enginering-backend,代码行数:18,代码来源:AuthJwtController.php

示例3: testNewCompany

 public function testNewCompany()
 {
     $response = $this->json('POST', '/companies/auth/register', ['name' => 'test', 'email' => 'test@test.com', 'password_confirmation' => 'testtest', 'password' => 'testtest']);
     $response->seeStatusCode(200);
     $this->seeInDatabase("companies", ['name' => 'test', 'email' => 'test@test.com']);
     $token = json_decode($response->response->content(), true);
     $token = $token['token'];
     /**
      * @var $company \plunner\Company
      */
     $company = JWTAuth::authenticate($token);
     $this->assertEquals('test@test.com', $company->email);
 }
开发者ID:dsd-meetme,项目名称:backend,代码行数:13,代码来源:CompaniesAuthTest.php

示例4: boot

 /**
  * Bootstrap the application services.
  *
  * @param Request $request
  */
 public function boot(Request $request)
 {
     view()->composer('index', function ($view) use($request) {
         $jwt_token = $request->cookie('jwt');
         if ($jwt_token) {
             try {
                 $user = JWTAuth::authenticate($jwt_token);
                 $view->with('user', $user);
             } catch (\Exception $e) {
             }
         }
     });
 }
开发者ID:mcculley1108,项目名称:admin.faithpromise.org,代码行数:18,代码来源:ComposerServiceProvider.php

示例5: createSession

 /**
  * Create Session for FE
  * @param Request $request
  */
 public function createSession(Request $request)
 {
     $session = md5(time());
     $create = $request->all();
     $create['session'] = $session;
     $token = JWTAuth::getToken();
     if ($token) {
         try {
             $user = JWTAuth::authenticate($token);
             if ($user != false) {
                 $create['user_id'] = $user->id;
             }
         } catch (\Exception $e) {
         }
     }
     $data = $this->dataRepository->insert($create);
     if ($data instanceof MessageBag) {
         return response()->json($data)->setStatusCode(412, 'Invalid session create');
     }
     return response()->json(['session' => $session])->setStatusCode(200, 'Session created');
 }
开发者ID:fredlawl,项目名称:planebox-api,代码行数:25,代码来源:DataController.php


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