Skip to content

Adding authentication with Auth0 #20

Merged
gnimnix merged 4 commits intomainfrom
ernesttanhk/rhd-10-implement-authentication-nextauth
Jan 5, 2025
Merged

Adding authentication with Auth0 #20
gnimnix merged 4 commits intomainfrom
ernesttanhk/rhd-10-implement-authentication-nextauth

Conversation

@HiokKuek
Copy link
Copy Markdown
Contributor

/login route (prior to login)
image

/profile route (after authentication)
image

  1. Setup sign in with google idp
  2. Redirect to home page upon successful login on google's landing page
  3. Refactored /profile page

@linear
Copy link
Copy Markdown

linear bot commented Oct 13, 2024

@HiokKuek
Copy link
Copy Markdown
Contributor Author

HiokKuek commented Oct 13, 2024

will add email based authentication once yall think its okay.

Also needa change header for mobile layout

following env variables are required (don't kill me pls)

NEXTAUTH_SECRET="Wb8I+ErhxbYC3KjfUzrdnqwBTQgYEAewlXw4xxRxoYQ="
NEXTAUTH_URL="http://localhost:3000"

GOOGLE_CLIENT_ID="1032390167615-favee3rhd9pofcifi30sl2jnn7ggnd3n.apps.googleusercontent.com"
GOOGLE_CLIENT_SECRET="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"

<a
className="self-center font-semibold text-indigo-600 hover:text-white"
href="/profile"
>{`Hello ${session?.user.name}!`}</a>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

May be better to display the avatar instead of the text here

},
callbacks: {
async redirect({ baseUrl }) {
// Redirect users to the /profile route after login
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Current rerouting is done to base directory not profile

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops ya, forgot to change the comment but I decided to route to / instead of /profile because in the event that user log out, the same callback url will be used and it will be weird for users to be routed to /profile when they are not authenticated.

<h1>Profile Page</h1>
<p>Welcome to your profile page!</p>
<div className="flex flex-col items-center justify-center p-6">
<Avatar className="flex h-[100px] w-[100px] items-center justify-center overflow-auto rounded-full bg-gray-500">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I like how you did this

@keithxun
Copy link
Copy Markdown
Contributor

Tested working functionality with gmail. Display of avatar and name all works well.

However, we will probably need a our own db of users so that we can verify users are from rh (@chuahziyang confirm?). Thus. there may be a need to authenticate against our own db instead.

@gnimnix gnimnix merged commit 48c30b7 into main Jan 5, 2025
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.

3 participants