Strapi no JWT token return on auth/local/register

974 Views Asked by At

Using Strapi v3.1.7. When sending a request to the endpoint "auth/local/register", i got the new created user but no JWT token as said in the doc.

request API Strpi registration

2

There are 2 best solutions below

0
On

For anyone who might be wondering, this is not really a bug it's a feature. See: https://github.com/strapi/strapi/pull/2916

If you have enabled email confirmation for user registration, by default it will remove jwt from the payload as the email is yet to be confirmed by the user. However, there is no mention about this AFAIK in the docs right now.

1
On

Either disable email confirmation for user registration setting (easier but less secure), or use a register flow like so:

  1. send register POST request to /auth/local/register
  2. inform user they must check email to verify email
  3. ask user to sign-in (POST to /auth/local), or auto sign them based on the above
  4. save JWT from sign-in request