简体   繁体   中英

Set different santum token expiration base on user role using laravel

I know I can set sanctum token expiration time in config/sanctum.php but this expiration seems to be global. How can I set a different expiration time base on their role. eg super admin token should expire after 30 minutes while admin should expire after 15 minute.

While authenticating a user, You can dynamically set 'expiration' key of sanctum configuration based on your user type.

config(['sanctum.expiration' => 525600]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM