-
Notifications
You must be signed in to change notification settings - Fork 10
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
client/src/context/auth-context.js
Outdated
let loginUser = async (e) => { | ||
e.preventDefault(); | ||
let response = await fetch( | ||
'http://127.0.0.1:8000/api/auth/generatetokens', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
client/src/context/auth-context.js
Outdated
|
||
let loginUser = async (e) => { | ||
e.preventDefault(); | ||
let response = await fetch( |
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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
client/src/context/auth-context.js
Outdated
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 |
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
client/src/context/auth-context.js
Outdated
setAuthTokens(null); | ||
setUser(null); | ||
localStorage.removeItem('authTokens'); | ||
history.push('/login'); |
There was a problem hiding this comment.
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().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
client/src/context/auth-context.js
Outdated
clearTimeout(logoutTimer); | ||
const updateToken = async () => { | ||
let response = await fetch( | ||
'http://127.0.0.1:8000/api/auth/generatetokens', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
client/src/context/auth-context.js
Outdated
if (logoutTimer) { | ||
clearTimeout(logoutTimer); | ||
const updateToken = async () => { | ||
let response = await fetch( |
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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
client/src/context/auth-context.js
Outdated
login: loginHandler, | ||
logout: logoutHandler, | ||
}; | ||
let onehrs = 1000 * 60 * 60; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DONE
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.