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

Adding authentication with Auth0 #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HiokKuek
Copy link
Collaborator

/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

Copy link

linear bot commented Oct 13, 2024

@HiokKuek
Copy link
Collaborator 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
Collaborator

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
Collaborator

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
Collaborator 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
Collaborator

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
Collaborator

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.

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.

2 participants