-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
feat (platform) : implemented Github auth #517
Conversation
PR Reviewer Guide 🔍(Review updated until commit 644eedc)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 644eedc
Previous suggestionsSuggestions up to commit 5bf82d3
|
apps/api/package.json
Outdated
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.
I'm not sure why you would need to change the API layer
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.
small mistake. I was tinkering with the backend and forgot to unstage the changes :)
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.
A lot of code in this file is unnecesary and non related
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.
This file is irrelevant aswell
Persistent review updated to latest commit 644eedc |
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.
All of the authentication logic is taken care of in the backend itself. You would just need to configure these things:
- How the button works
- What happens after the backend redirects to the oauth success page.
I would recommend you to manually run the authentication once.
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.
After clicking the button, the user is redirected to a GitHub auth screen. Then, an API request is made to fetch user data along with a token. I set the email state and redirect the user to the /account-details page, where everything works fine up to this point
the response includes this message
If you could explain what it means, then maybe I could do something. Otherwise, it's a dead end for me :)
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.
I'll fix cookies give me a moment
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.
@poswalsameer can you please look into this PR? Auth is not working as expected
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.
@poswalsameer can you please look into this PR? Auth is not working as expected
Sure.
} | ||
} catch (error) { | ||
// eslint-disable-next-line no-console -- we need to log the error | ||
console.error(`Failed to fetch user data: ${error}`) |
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.
If you could add toast messages to handle the error states in a well-mannered way, then that would be really nice.
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.
Yeah, I planned to do this after implementing the functionalities first, but then I got stuck and someone asked me to send the PR for review. Is it working fine on your end?
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.
Yeah, I planned to do this after implementing the functionalities first, but then I got stuck and someone asked me to send the PR for review. Is it working fine on your end?
What's the problem you are facing?
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.
After clicking the button, the user is redirected to a GitHub auth screen. Then, an API request is made to fetch user data along with a token. I set the email state and redirect the user to the /account-details page, where everything works fine up to this point
the response includes this message
If you could explain what it means, then maybe I could do something. Otherwise, it's a dead end for me :)
this is the problem
} | ||
} else { | ||
// eslint-disable-next-line no-console -- we need to log the error | ||
console.error('No authorization code found in the URL') |
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.
Add toast here too. Go through the Figma file to know the color scheme.
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.
got it 👍
if (code) { | ||
try { | ||
const response = await fetch( | ||
`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/github/callback?code=${code}`, |
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.
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.
I am hitting this url and it redirects to a page (wherever i want) with a code but to get the user details i have to fetch the data from here
${process.env.NEXT_PUBLIC_BACKEND_URL}/api/auth/github/callback?code=${code}
this return a JSON object with user details and token. but the main problem is here
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.
Here's the flow @dev-palwar:
- On clicking the GitHub button, users should be redirected to
<API_BASE_URL>/api/auth/github
- The API handles all the logic in here and then sends the user to github auth page.
- The user authenticates themselves on github
- Github sends back a redirect to the API with authentication success.
- The backend then sends back a redirect to a
<FRONTEND_BASE_URL>/oauth/signin
and attaches adata
query object to this redirect url that has all the user data.
@dev-palwar hey bro, any news on this? |
@rajdip-b yeah i was busy with my practicals. Will start working on it now! |
Hey @dev-palwar how is this issue going on |
I was stuck at this and did not get any response. |
User description
Description
implemented github based authentication for the platform app. btw for testing put
GITHUB_CALLBACK_URL="http://localhost:3025/auth"
Fixes #307
Dependencies
Installed the types for passport
Future Improvements
Mention any improvements to be done in future related to any file/feature
Mentions
Mention and tag the people
Screenshots of relevant screens
Add screenshots of relevant screens
Developer's checklist
If changes are made in the code:
Documentation Update
PR Type
enhancement
Description
useEffect
to manage the GitHub redirect logic upon component mount.User
type to handle user data received from the backend.Changes walkthrough 📝
page.tsx
Implement GitHub OAuth login and redirect handling
apps/platform/src/app/auth/page.tsx
useEffect
to manage GitHub redirect logic.User
type for handling user data.