本文整理汇总了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);
}
示例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]);
}
示例3: me
protected function me()
{
if ($token = JWTAuth::getToken()) {
return JWTAuth::parseToken()->toUser();
}
return false;
}
示例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;
}
示例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);
}
}
示例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];
}
示例7: destroy
public function destroy()
{
$user = JWTAuth::parseToken()->authenticate();
if ($user) {
User::destroy($user->id);
return response('Success');
} else {
return response('Unathorized', 403);
}
}
示例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);
}
示例9: currentUserIsOwner
public function currentUserIsOwner()
{
$user = JWTAuth::parseToken()->authenticate();
$user_id = $user->id;
if ($this->user_id == $user_id) {
return true;
} else {
return false;
}
}
示例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;
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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');
}