-
-
Notifications
You must be signed in to change notification settings - Fork 170
Fix callback getting appended to the url when signin button is clicked on login page #1178
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| "use client"; | ||
| import { api } from "@/server/trpc/react"; | ||
| import { usePathname } from "next/navigation"; | ||
| import { | ||
| Disclosure, | ||
| DisclosureButton, | ||
|
|
@@ -40,6 +41,8 @@ const Nav = ({ | |
| enabled: session ? true : false, | ||
| }); | ||
|
|
||
| const pathname = usePathname(); | ||
|
|
||
| const userNavigation = [ | ||
| { | ||
| name: "Your Profile", | ||
|
|
@@ -55,6 +58,18 @@ const Nav = ({ | |
|
|
||
| const hasNotifications = !!count && count > 0; | ||
|
|
||
| const handleSignInPageNavigation = () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! This is very much a minor issue but it annoyed me and means we need to add guards in E2E tests. This will remove that need
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I am happy to help :) Helping maintainers to solve these minor but time consuming issues is my goal for this Hacktoberfest. |
||
| /** | ||
| * * NextAuth.js automatically adds current url to the callbackurl prop in the singin() method. | ||
| * * As Navbar is always present, spamming SignIn button causes login page url getting appended in the url bar. | ||
| */ | ||
| if (pathname === "/get-started") { | ||
| return; | ||
| } | ||
|
|
||
| signIn(); | ||
| }; | ||
|
|
||
| return ( | ||
| <Disclosure as="nav" className="bg-neutral-100 dark:bg-black"> | ||
| {({ close, open }) => ( | ||
|
|
@@ -117,12 +132,15 @@ const Nav = ({ | |
| </> | ||
| ) : ( | ||
| <> | ||
| <button className="nav-button" onClick={() => signIn()}> | ||
| <button | ||
| className="nav-button" | ||
| onClick={handleSignInPageNavigation} | ||
| > | ||
| Sign in | ||
| </button> | ||
| <button | ||
| className="primary-button" | ||
| onClick={() => signIn()} | ||
| onClick={handleSignInPageNavigation} | ||
| > | ||
| Sign up for free | ||
| </button> | ||
|
|
||
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.
How come you needed to change the order of these?
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 is part of an already merged change, I had done a git pull from upstream after committing my changes and since I had global rebase to true, it caused this commit to be moved ahead of my commit.
Reference to the merged commit
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.
Ok this makes sense. Thanks for the clarification