Joseph Morgan
Published in : 2022-07-16
How to Increase Sanctum token length in Laravel 9?
this is my login function which generate the token
<?php if(Auth::attempt(['email' => request('email') , 'password' => request('password')])){ $token = Auth::user()->createToken('authentication')->plainTextToken; $lastLogin = User::find(Auth::user()->id); $lastLogin->last_login = Carbon::now()->format('Y-m-d\TH:i:s.vP'); $lastLogin->save(); return response()->json([ "user" => Auth::user(), "token" => $token ], 200); } else { return response()->json(['Error, Wrong email or password'], 400); } ?>
and the token which generated by this function is too small
5|FHtT0lg8w3AxJvIGYhxVf2PBYuGjgw3xALYDqkr8
How can I generate it like the Regular Bearer token? Any solution please
Join our community and get the chance to solve your code issues & share your opinion with us
Sign up Now
Mohamed Atef Date : 2022-07-16
Best answers
51
Best answers
51
Yes i believe you can do this, using this function in your User module
and don't forget to use
at the top of your Module
Joseph Morgan Date : 2022-07-16
Thank you, I will try this function