Hi Bora, You are right. You can store the JWT in the local storage and pass it in the request header every time in the API.
For displaying current user profile you can create an API (Ex: /profile) and just add the before_action: authenticate_and_set_user and you will have the current logged in user object in the @current_user instance variable which you can send in the response and use it in the Front end. You can call this API request whenever your web app loads in the browser and show those details.
Yeah, I have handled it that way, the only thing it is missing is the forgot password functionality. I think I can just update the password field of the user by sending a a request to the controller with the token. That should do it securely I assume. Thank you for your help again Gokul. Really appreciated.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Bora, You are right. You can store the JWT in the local storage and pass it in the request header every time in the API.
For displaying current user profile you can create an API (Ex:
/profile
) and just add thebefore_action: authenticate_and_set_user
and you will have the current logged in user object in the@current_user
instance variable which you can send in the response and use it in the Front end. You can call this API request whenever your web app loads in the browser and show those details.Let me know if this clarifies.
Yeah, I have handled it that way, the only thing it is missing is the forgot password functionality. I think I can just update the password field of the user by sending a a request to the controller with the token. That should do it securely I assume. Thank you for your help again Gokul. Really appreciated.