PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, February 21, 2022

[FIXED] JWT token revoke for specific user on deactivate account

 February 21, 2022     jwt-auth, laravel, php     No comments   

Issue

So far I have created a database with

user_id,token.

It stores all the logged in user's token.

I have fetched all the tokens from database by user_id. Then loop through,

JWTAuth::invalidate(new \Tymon\JWTAuth\Token($token->token));

Its not working. Third party package: Tymon Laravel JWT

How to achieve this functionality?


Solution

Just adding here the comment of Harpal singh.It solved my issue.

"you can create a middleware to check if account is deactivated then add

JWTAuth::invalidate(new \Tymon\JWTAuth\Token($token->token)); 

to invalidate the user. By doing this if deactivated user trying to access routes, he will not get access."



Answered By - Shifat
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing