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


PHP JWTAuth::parseToken方法代码示例

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


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

示例1: inValidateToken

 public function inValidateToken()
 {
     $tempStorage = app('\\App\\Http\\Controllers\\TEMPStorage\\UserTempStorage');
     $tempStorage->forget('id_company');
     //set model login
     $user = JWTAuth::parseToken()->authenticate();
     $this->model->find($user->id)->update(['login' => 0]);
     JWTAuth::invalidate(JWTAuth::getToken());
     return API::response()->array(['message' => 'success'])->statusCode(200);
 }
开发者ID:masmike,项目名称:scafolding,代码行数:10,代码来源:AuthController.php

示例2: addPoint

 public function addPoint(Request $request)
 {
     $user = JWTAuth::parseToken()->authenticate();
     $user->points = $user->points + $request->input('amount');
     $user->save();
     return response()->json(['success' => true, 'message' => "Users points added", 'users' => $user]);
 }
开发者ID:jubaedprince,项目名称:nohunchAPI,代码行数:7,代码来源:UserController.php

示例3: me

 protected function me()
 {
     if ($token = JWTAuth::getToken()) {
         return JWTAuth::parseToken()->toUser();
     }
     return false;
 }
开发者ID:zenoZz,项目名称:laravelapi,代码行数:7,代码来源:BaseController.php

示例4: __construct

 public function __construct(User $user, Project $project, Invitation $invitation)
 {
     $this->loggedUser = JWTAuth::parseToken()->authenticate();
     $this->user = $user;
     $this->project = $project;
     $this->invitation = $invitation;
 }
开发者ID:rasparac,项目名称:diplomski,代码行数:7,代码来源:UsersController.php

示例5: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $aplicacion)
 {
     $metodo = $request->method();
     $user = JWTAuth::parseToken()->authenticate();
     switch ($metodo) {
         case 'GET':
             $tipo_permiso = 1;
             break;
         case 'POST':
             $tipo_permiso = 2;
             break;
         case 'PUT':
             $tipo_permiso = 2;
             break;
         case 'DELETE':
             $tipo_permiso = 2;
             break;
     }
     $privilegios = Privilegio::with('aplicacion')->where('user_id', $user->id)->where('aplicacion_id', $aplicacion);
     if ($tipo_permiso == 1) {
         $privilegios = $privilegios->where(function ($query) {
             $query->where('privilegios_tipo_id', 1)->orWhere('privilegios_tipo_id', 2);
         });
     } else {
         $privilegios = $privilegios->where('privilegios_tipo_id', $tipo_permiso);
     }
     $privilegios = $privilegios->first();
     if ($privilegios) {
         return $next($request);
     } else {
         return response('Unauthorized.', 401);
     }
 }
开发者ID:antoniopacheco,项目名称:CECINTRANET-API,代码行数:40,代码来源:PermisoAplicacion.php

示例6: refreshToken

 /**
  * Permintaan refresh token
  *
  * @param Request $request
  * @return array
  */
 public function refreshToken(Request $request)
 {
     $this->middleware('auth');
     $user = app('auth')->user();
     $newToken = JWTAuth::parseToken()->refresh();
     return ['status' => 'success', 'user' => $user, 'token' => $newToken];
 }
开发者ID:amteknologi,项目名称:e-commerce,代码行数:13,代码来源:LoginController.php

示例7: destroy

 public function destroy()
 {
     $user = JWTAuth::parseToken()->authenticate();
     if ($user) {
         User::destroy($user->id);
         return response('Success');
     } else {
         return response('Unathorized', 403);
     }
 }
开发者ID:mkhrystunov,项目名称:laravel_test,代码行数:10,代码来源:UserController.php

示例8: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param int $level
  * @return mixed
  * @throws \Bican\Roles\Exceptions\LevelDeniedException
  */
 public function handle($request, Closure $next, $level)
 {
     if (!($user = JWTAuth::parseToken()->authenticate())) {
         return response()->json(['user_not_found'], 404);
     }
     if ($user->level() >= $level) {
         return $next($request);
     }
     throw new LevelDeniedException($level);
 }
开发者ID:johnnymn,项目名称:roles-jwt,代码行数:19,代码来源:VerifyLevel.php

示例9: currentUserIsOwner

 public function currentUserIsOwner()
 {
     $user = JWTAuth::parseToken()->authenticate();
     $user_id = $user->id;
     if ($this->user_id == $user_id) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:jubaedprince,项目名称:nohunchAPI,代码行数:10,代码来源:Question.php

示例10: checkUserIsLogged

 protected function checkUserIsLogged()
 {
     $user = JWTAuth::parseToken()->authenticate();
     if (!$user) {
         return response()->json(["msg" => "You must be authenticated", "data" => false], 404);
     } else {
         $this->user = $user;
         return true;
     }
 }
开发者ID:absis,项目名称:EsmorzarsIBenzina,代码行数:10,代码来源:Controller.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (count(Enseignant_Privilege::where(function ($query) {
         $query->where('id_Enseignant', '=', JWTAuth::parseToken()->toUser()->id_Enseignant)->where('id_Privilege', '=', '7');
     })->get()) > 0) {
         return $next($request);
     } else {
         return Response::json(['error' => 'Permission denied'], HttpResponse::HTTP_UNAUTHORIZED);
     }
 }
开发者ID:S4M37,项目名称:Project_GangOfThree,代码行数:17,代码来源:OrganisateurPrivilegeMiddleware.php

示例12: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @param int|string $permission
  * @return mixed
  * @throws \Sim\Roles\Exceptions\PermissionDeniedException
  */
 public function handle($request, Closure $next, $permission)
 {
     if (!($user = JWTAuth::parseToken()->authenticate())) {
         return response()->json(['user_not_found'], 404);
     }
     if ($user->can($permission)) {
         return $next($request);
     }
     throw new PermissionDeniedException($permission);
 }
开发者ID:johnnymn,项目名称:roles-jwt,代码行数:19,代码来源:VerifyPermission.php

示例13: destroy

 public function destroy($id)
 {
     $user = JWTAuth::parseToken()->authenticate();
     $todo = Todo::where('owner_id', $user->id)->where('id', $id)->first();
     if ($todo) {
         Todo::destroy($id);
         return response('Success');
     } else {
         return response('Unathorized', 403);
     }
 }
开发者ID:mkhrystunov,项目名称:laravel_test,代码行数:11,代码来源:TodoController.php

示例14: edit_profile

 public function edit_profile(Request $request)
 {
     $validator = Validator::make($request->all(), ['full_name' => 'required|max:50', 'user_name' => 'required|max:30', 'email' => 'required|email|max:50', 'address' => 'required|max:50']);
     if ($validator->fails()) {
         $data['errors'] = $validator->errors()->first();
         return response()->json($data, 201);
     }
     $user = JWTAuth::parseToken()->authenticate();
     $user = user::find($user->id);
     $user->update($request->all());
     $data['result'] = $user;
     return response()->json($data, 200);
 }
开发者ID:saidur92,项目名称:Laravel-basic-curd-by-me,代码行数:13,代码来源:apiController.php

示例15: MenuRolePermission

 /**
  * get his permission
  */
 public function MenuRolePermission()
 {
     $user = JWTAuth::parseToken()->authenticate();
     $this->id_role = $user->id_role;
     $data = new \App\Api\Model\Menu();
     $permission = \App\Api\Model\Permission::all();
     foreach ($permission as $key => $value) {
         $this->value = $value;
         $data = $data->leftJoin('role_permissions as ' . $value->name, function ($join) {
             $join->on(DB::raw($this->value->name . '.id_menu'), '=', 'menus.id')->where(DB::raw($this->value->name . '.id_role'), '=', $this->id_role)->where(DB::raw($this->value->name . '.id_permission'), '=', $this->value->id);
         })->addSelect(DB::raw($value->name . '.id as ' . $value->name . 'ed'));
     }
     return $data->addSelect('menus.id', 'menus.name', 'menus.id_parent', 'menus.url', 'menus.icon', 'menus.order')->where('view.id', '>', '0')->orderBy('menus.id_parent')->orderBy('menus.order');
 }
开发者ID:masmike,项目名称:scafolding,代码行数:17,代码来源:Menu.php


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