Closed pwnz22 closed 5 days ago
Hey @pwnz22, since registration is not covered by the module, the token in API response won't be stored in the storage automatically. It is done only during login
, you can find the details in the docs.
The call of refreshIdentity
method after registration makes sense only with cookie mode since token will be propagated to the client automatically, however for token mode we have to work with token storage and this logic is encapsulated inside login
method.
If you want to make it work w/o calling login
then you can use token storage in your code by following the example used in the module - useSanctumAuth.ts, and after that refreshIdentity
method will do the rest.
Feel free to ask for assistance in writing this code if required!
Thanks for quick response. Okay, copied some code from useSanctumAuth.ts and now it's ok.
Thank you!
Describe the bug
Token mode not working properly when i register a user.
Registering user getting:
{token: token}
and it's not setting the token to cookies.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Login after registrating
Actual behavior
Not loggin after register. The refreshIdentity method returning error because token is not set.
Module information
0.5.0
nuxt.config.ts
:Nuxt environment:
3.13.0
Laravel environment:
11.9
config/session.php
:SESSION_DOMAIN=localhost
config/sanctum.php
:config/cors.php
:Logs
Please provide module logs that can help to understand the problem. Make sure to change
sanctum.logLevel
to5
in yournuxt.config.ts
. CSR logs can be found in the browser, while SSR logs can be found in the server terminal.Additional context
The login method works. Token is setting and
refreshIdentity
returning properly a user.