Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
fix: sign in redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
intergalacticspacehighway committed Nov 16, 2023
1 parent 0528cf5 commit 1916e09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions packages/app/components/login/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ export function Login() {
loading,
} = useLogin();
const privy = usePrivy();
//#endregion
const modalScreenContext = useModalScreenContext();

const user = useUser();
const router = useRouter();
const prevUser = usePreviousValue(user);
//#endregion
const modalScreenContext = useModalScreenContext();

useEffect(() => {
if (showSignMessage) {
Expand All @@ -42,13 +41,10 @@ export function Login() {
modalScreenContext?.setTitle("Sign in to collect & unlock");
}
}, [showSignMessage, modalScreenContext]);

useEffect(() => {
if (
user.isAuthenticated &&
!prevUser?.isAuthenticated &&
router.asPath === "/login"
) {
// This will happen when user is logged in after connect wallet.
// For social logins, privy refreshes the page so we don't need to do anything.
if (user.isAuthenticated && !prevUser?.isAuthenticated) {
router.pop();
}
}, [router, user, prevUser]);
Expand Down Expand Up @@ -87,7 +83,6 @@ export function Login() {
if (privy.authenticated) {
await privy.logout();
}
router.pop();
privy.login();
}}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/app/navigation/use-navigate-to.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const useNavigateToLogin = () => {
}),
Platform.select({
native: "/login",
web: router.asPath === "/" ? "/login" : router.asPath,
web: router.asPath,
}),
{ shallow: true }
);
Expand Down

0 comments on commit 1916e09

Please sign in to comment.