amrnn90 / breeze-nuxt

An application / authentication starter kit frontend in Nuxt3 for Laravel Breeze.
MIT License
198 stars 33 forks source link

Modify schema of login/register/password-reset etc. response #26

Open FrazeColder opened 9 months ago

FrazeColder commented 9 months ago

Hey there,

I have modified my backend and instead of just returning the token when the login route is called my backend returns such a response:

{
  "message": "You have been successfully logged in.",
  "data": {
    "user": {
      "id": 4,
      "username": "123",
      "email": "123@123.de",
      "products_count": 13,
      "comments_count": 646,
      "saved_products_count": 1,

    },
    "token": "104|Hd2TOnxPMTFcMdbN3MyLFsidmUGfiaety6ioBJkP4b6ae563"
  }
}

This means my login token cannot be retrieved by larafetch just by response.token. I need to change it to response.data.token as the token is part of the data object.

But how do I do this? I cannot find a single line of code where you set the Laravel Sanctum auth token to the header of the user. I can only see lines which are about the XSRF-Token.

I highly appreciate any kind of help!

Kind regards