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

Sdk6toast #11

Closed
wants to merge 8 commits into from
Closed

Sdk6toast #11

wants to merge 8 commits into from

Conversation

Sdk6
Copy link
Collaborator

@Sdk6 Sdk6 commented Oct 30, 2023

No description provided.

@R2bEEaton R2bEEaton self-requested a review October 30, 2023 22:10
Copy link
Owner

@R2bEEaton R2bEEaton left a comment

Choose a reason for hiding this comment

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

Right now the toast shows up all the time, but it should only show up on HomePage right after a login. Similarly, it should take you back to LoginPage and play a toast with an error if the login fails. Check my other comment for details.

import { useAuth } from 'src/auth'

const HomePage = () => {
const { currentUser, isAuthenticated } = useAuth()

toast.success(`Login successful, welcome ${currentUser.email}`)
Copy link
Owner

Choose a reason for hiding this comment

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

Here the toast is always played whenever a user visits that page. This means any time they refresh they will see the same toast. We only want it to happen right after they log in. Check this example for creating a dynamic toast, and the ability to add more readable error messages to oauth.js: https://redwoodjs.com/docs/how-to/oauth#better-error-handling

@Sdk6 Sdk6 closed this Oct 31, 2023
@Sdk6 Sdk6 reopened this Oct 31, 2023
@Sdk6
Copy link
Collaborator Author

Sdk6 commented Oct 31, 2023

i changed to show toast on the first login but im not sure how a google login fails, wouldnt they just automatically go back to login? I am going to sleep now but am happy to talk more about this later.

@R2bEEaton
Copy link
Owner

R2bEEaton commented Oct 31, 2023

What you have there looks great for showing the message on first login! As for showing login errors, you are right. Most of the login errors are caught by Google. But we get some of them.

Look in /api/src/functions/oauth/oauth.js
Line 37
Line 53

Both of these catch potential errors with the login. They currently just return an error message, but you should make them redirect back to routes.login() and show a toast with that error message.

Session is a good solution for homepage, but in this case you'll want a customizable method so I would recommend doing it with query string parameters as shown in the link I sent above.

@R2bEEaton
Copy link
Owner

Merged as part of #15 I think

@R2bEEaton R2bEEaton closed this Nov 9, 2023
@R2bEEaton R2bEEaton deleted the sdk6toast branch November 12, 2023 22:44
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