Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup authentication stacks closing #118 #180

Merged
merged 10 commits into from
Apr 21, 2023
Merged

Conversation

briswells
Copy link
Contributor

Everything is finally working together. On an login request frontend sends a post to backend who returns a JWT which gets set in local storage. When the front end calls an API route the JWT get added to the headers which the backend will use to check authentication. The token will remain until it expires allowing the user to remain logged in for the duration. The login state is being stored in a redux slice. When the app loads it checks for a valid token and if one is found sets the current user to logged in. This lets the user refresh the page and remain logged in. I'm sure there are better ways to implement this but I couldn't figure them out as I'm not a front end expert.

When the user logs out the token is removed from their local storage.

The main issue I can see right now is on a refresh other values in the userSlice are deleted, but this probably could be solved with a route to the backend that retrieves the information on a refresh. Tokens are also not removed server side until they expire, this means after someone logs out the server still would accept their token, but this can be figured out at a later point.

@briswells briswells force-pushed the setup-authentication branch from 4fed34e to da301bf Compare April 21, 2023 01:35
@briswells briswells changed the title Setup authentication Setup authentication stacks closing #118 Apr 21, 2023
@briswells briswells force-pushed the setup-authentication branch from da301bf to b38421c Compare April 21, 2023 01:37
Copy link
Contributor

@MSS-Shalavritha MSS-Shalavritha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @briswells, Just tested the PR, it is working as expected now. Attaching the docker log screenshot for your reference.
Screenshot 2023-04-20 at 9 53 38 PM

@hardikpatil
Copy link
Contributor

I am not able to get pass through :/

Screenshot 2023-04-21 at 10 20 54

@hardikpatil
Copy link
Contributor

Hi @briswells, Just tested the PR, it is working as expected now. Attaching the docker log screenshot for your reference. Screenshot 2023-04-20 at 9 53 38 PM

@MSS-Shalavritha in what context?

@briswells
Copy link
Contributor Author

I am not able to get pass through :/

Screenshot 2023-04-21 at 10 20 54

Did you fetch/pull most recent changes and build the containers? Also, what is the docker console saying. I was talking with @MSS-Shalavritha last night and he was testing on a freshly built container, testing that logging in using the stock account created in dummy data.

@MSS-Shalavritha
Copy link
Contributor

Hi @briswells, Just tested the PR, it is working as expected now. Attaching the docker log screenshot for your reference. Screenshot 2023-04-20 at 9 53 38 PM

@MSS-Shalavritha in what context?

As @briswells mentioned, I tested on freshly built container yesterday, logged in and navigated to different webpages, it was working as expected, I retested it again today without building a new container, it still seems to be working fine. Attaching the screenshot for your reference.
Screenshot 2023-04-21 at 11 58 03 AM

@AbhinavReddy-Dev
Copy link
Contributor

@briswells @MSS-Shalavritha what are the login credentials to verify this? Can someone please provide them, I can't login from React frontend: 3000 port.

@MSS-Shalavritha
Copy link
Contributor

MSS-Shalavritha commented Apr 21, 2023

@briswells @MSS-Shalavritha what are the login credentials to verify this? Can someone please provide them, I can't login from React frontend: 3000 port.

@AbhinavReddy-Dev, Credentials, I'm using are:

Username: [email protected]
Password : password

Copy link
Contributor

@AbhinavReddy-Dev AbhinavReddy-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me with the credentials mentioned above.

@hardikpatil
Copy link
Contributor

@briswells @MSS-Shalavritha what are the login credentials to verify this? Can someone please provide them, I can't login from React frontend: 3000 port.

@AbhinavReddy-Dev, Credentials, I'm using are:

Username: [email protected] Password : password

worked with these credentials though!

@AbhinavReddy-Dev AbhinavReddy-Dev merged commit f86fad0 into main Apr 21, 2023
@AbhinavReddy-Dev AbhinavReddy-Dev deleted the setup-authentication branch April 21, 2023 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Properly Set up login
5 participants