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

Adds Login functionality #23

Merged
merged 5 commits into from
Mar 18, 2022
Merged

Adds Login functionality #23

merged 5 commits into from
Mar 18, 2022

Conversation

maxcell
Copy link
Contributor

@maxcell maxcell commented Mar 18, 2022

Summary

We have a working login now 🙌🏾. This will allow users to send their credentials in and then redirect them to the stubbed out /notes page. This does not perform any sorts of visual errors so this is fully happy path code for now.

Technical Detail

Very very similar to the #16 in terms of logic. The biggest things we did differently is instead make a request to Supabase so we can make sure that we successfully have a user and then we return the profile for that user.

Outline of flow:

  • A user navigates to the /login page. This will first run the loader function to determining if we have a user session already if not it will pass through with the rest of the rendering.
  • A user will see what's in the Login function and allow them to fill in their credentials
  • Once a user clicks the submit button this will fire off the action function
  • The action function will go off and verify if the user exists through Supabase. If it does, it will return back the profile associated with the user.
  • Then the user's id should be stored within the session cookie
  • We then redirect the user to the /notes page
  • In the Web console you should expect to see the Session cookie __session

One thing I came across is that we shouldn't actually hash the passwords on our end because Supabase performs that work already for us with its auth client (see here). This will make the user code much nicer for folks.

side note: We will want to add form validations for #17 so like I said only happy path so far.

Manual Testing

**If you don't already have an account**
  • To sign up with an account, go to /join, use a valid email and a 6 character password.
  • This will redirect you to the index page, this will mean you need to remove the session cookie to login in.

Picture of me right clicking the __session cookie and deleting

To test sign in, (I have created a user with [email protected] and prince):

  • As a signed up user, you should be able to go to /login and be prompted to log in with your user name and password
  • After submitting you should then be able to see the /notes page with a stubbed out notes HTML of Notes scaffold.

Relevant Documentation and Issues

@maxcell maxcell self-assigned this Mar 18, 2022
@netlify
Copy link

netlify bot commented Mar 18, 2022

✅ Deploy Preview for kpop-stack ready!

🔨 Explore the source changes: 2a2da4f

🔍 Inspect the deploy log: https://app.netlify.com/sites/kpop-stack/deploys/6234dd0842bbf40008f1973d

😎 Browse the preview: https://deploy-preview-23--kpop-stack.netlify.app

This uses the direct styles from the Remix stacks. Closes #20.
This uses the direct styles from the Remix stacks. Closes #20.
@@ -35,7 +35,7 @@ export const action: ActionFunction = async ({ request }) => {
return createUserSession({
request,
userId: user.id,
remember: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I needed this for a hot second to test something but no longer necessary

@@ -9,7 +9,7 @@ export const sessionStorage = createCookieSessionStorage({
path: "/",
sameSite: "lax",
secrets: ["SUPERSECRET_SECRET"],
secure: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This would be more appropriate for a production application so I needed to change this. I had to verify some testing before locally to see how this reacted

Comment on lines -13 to -14
const hashedPassword = await bcrypt.hash(password, 10);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mentioned this in the PR but Supabase hashes our pass word already when we surface through the supabase.auth commands so I feel like we don't need to actually hash!

Copy link
Contributor

@tzmanics tzmanics left a comment

Choose a reason for hiding this comment

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

this works great, woohoo!

@maxcell maxcell merged commit 4afc1ec into main Mar 18, 2022
@maxcell maxcell deleted the pw/12/loginPage branch March 18, 2022 20:23
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.

Add styling for Join and Login Page Adds login page Add user login with Supabase Auth
2 participants