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

OAuth2.0 Implementation frontend ~ Mayank, Bhanu #120

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

mayank0508
Copy link

@mayank0508 mayank0508 commented Mar 6, 2022

Description

Implemented OAuth2.0 on the frontend

References

Add any reference to previous pull-request or issue
Fixes #117

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

@NVombat NVombat changed the title Issue #117 I have requested for a pull request, contact me if the changes break the code ~ Mayank, Bhanu OAuth2.0 Implementation frontend ~ Mayank, Bhanu Mar 6, 2022
Copy link
Collaborator

@shvam0000 shvam0000 left a comment

Choose a reason for hiding this comment

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

Please look into the comments and make the changes accordingly.

Also keep looking for how to work on change and reset password feature.

let loginUser = async (e) => {
e.preventDefault();
let response = await fetch(
'http://127.0.0.1:8000/api/auth/generatetokens',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we change this API URL to the actual one? Try putting it in .env file and fetch it from there.
Please update the .env.example file as well if needed.

Copy link
Author

Choose a reason for hiding this comment

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

DONE


let loginUser = async (e) => {
e.preventDefault();
let response = await fetch(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change 'fetch' to 'axios'

Copy link
Author

Choose a reason for hiding this comment

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

but we aren't using Axios, we are just using the fetch command to do it, I think changing it to Axios might break it! do we need to do it via using Axios interceptors

setAuthTokens(data);
setUser(jwt_decode(data.access_token));
localStorage.setItem('authTokens', JSON.stringify(data)); // here is the code that will be used to storedToken
history.push('/profile'); // this will send the user to the profile page the moment he logs in
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use history.replace() method instead history.push().

Copy link
Author

Choose a reason for hiding this comment

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

DONE

setAuthTokens(null);
setUser(null);
localStorage.removeItem('authTokens');
history.push('/login');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use history.replace() method instead history.push().

Copy link
Author

Choose a reason for hiding this comment

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

DONE

clearTimeout(logoutTimer);
const updateToken = async () => {
let response = await fetch(
'http://127.0.0.1:8000/api/auth/generatetokens',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we change this API URL to the actual one? Try putting it in .env file and fetch it from there.
Please update the .env.example file as well if needed.

Copy link
Author

Choose a reason for hiding this comment

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

DONE

if (logoutTimer) {
clearTimeout(logoutTimer);
const updateToken = async () => {
let response = await fetch(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please change 'fetch' to 'axios'

Copy link
Author

Choose a reason for hiding this comment

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

but we aren't using Axios, we are just using the fetch command to do it, I think changing it to Axios might break it! do we need to do it via using Axios interceptors

login: loginHandler,
logout: logoutHandler,
};
let onehrs = 1000 * 60 * 60;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use camCasing for defining variables.

Copy link
Author

Choose a reason for hiding this comment

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

DONE

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.

Implement OAuth 2.0 on frontend
3 participants