Remember Users & Forgot Password Functionality in Laravel 5.1 and Angular JS (JWT Authentication)
Asked Answered
G

2

11

I am using laravel 5 and angular js and JWT authentication for logging and registering my users. But there is nothing mentioned about to facilitate users with remember me functionality and also allow users to reset password when forgotten password.

I researched a lot and didn't find exactly what I need though the answer in following link is helpful but inadequate for me to proceed. Laravel 5 Password Reset with Angular View

Kindly provide any information and links that would be helpful. Thanks in advance! :)

Gregoire answered 25/9, 2015 at 13:21 Comment(1)
Password Rests come in a large variety, can you be more specific, what was inadequate about the question you linked, so we can be more specific with out answers.Grallatorial
G
4

To Answer from a JWT perspective.

Remember me is essentially asking the user how long they want to login for. Depending on the security requirements and typical usage patterns of your users, short sessions are often from 15 minutes and up to a browser session. Long sessions (selecting Remember me) can be anything from 24hours to a year.

The JWT issuer can set the exp claim (expiration time of the token) differently depending on the user's selection of the 'Remember Me' checkbox.

If you're intending the 'Remember Me' to last longer than a single browser session, the simplest way is to store the token in a cookie. This means the cookie also needs to have the following properties set: httponly, secure, and expires (with the same expiry time as the exp claim from the token).

Rest Password implementations come in many shapes and sizes depending on your requirements. These are not directly related to JWTs as they come before the JWT issuer will issue a token.

Grallatorial answered 10/8, 2016 at 14:12 Comment(1)
Thanks for the reply @Alex.Gregoire
U
1

You're asking for something that will need to be handled specifically for your case. The way most "remember me" systems work (including Laravel) is via storing a cookie on the user's device. That cookie is then used to authenticate automatically when the user returns. JWT is different as you are given a token, rather than a cookie, that you pass back to the server in a header. They are both essentially strings of letters and numbers, but you'll specifically have to store the JWT token on the user's browser in order for a "remember me" type of functionality. You might do this in the Angular app using localStorage or some other similar front-end practice.

For the forgotten password, you can submit the same form fields that are default to Laravel and simply override how the PasswordController returns the response; in this case needing a JSON response rather than a redirect.

Underwent answered 5/8, 2016 at 18:19 Comment(1)
Thanks for the reply @AdamGregoire

© 2022 - 2024 — McMap. All rights reserved.