Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix redirect after password update

Tomas Valenta8028ec166813
diff --git a/apps/web/src/components/AuthForm.tsx b/apps/web/src/components/AuthForm.tsx
index 9e46b2587..fa4566161 100644
--- a/apps/web/src/components/AuthForm.tsx
+++ b/apps/web/src/components/AuthForm.tsx
@@ -28,7 +28,11 @@ function AuthForm({ view }: Props) {
if (user.user && redirectTo) {
router.push(redirectTo)
}
- }, [user.user, router, redirectTo])
+
+ if (user.wasUpdated && !redirectTo) {
+ router.push('/dashboard')
+ }
+ }, [user.user, router, redirectTo, view, user.wasUpdated])
return (
<div className="mx-auto flex flex-1 w-full justify-center items-center flex-col pt-4">
@@ -40,6 +44,7 @@ function AuthForm({ view }: Props) {
</h1>
<div className="md:w-[420px] w-[240px]">
<Auth
+ otpType={view === 'update_password' ? 'recovery' : undefined}
supabaseClient={supabase}
appearance={{
theme: ThemeSupa,
diff --git a/apps/web/src/utils/useUser.tsx b/apps/web/src/utils/useUser.tsx
index b16820950..826807a08 100644
--- a/apps/web/src/utils/useUser.tsx
+++ b/apps/web/src/utils/useUser.tsx
@@ -35,6 +35,7 @@ type UserContextType = {
})
| null;
error: Error | null;
+ wasUpdated: boolean | null;
}
export const UserContext = createContext(undefined)
@@ -47,6 +48,8 @@ export const CustomUserContextProvider = (props) => {
const [isLoading, setIsLoading] = useState(true)
const mounted = useRef<boolean>(false)
+ const [wasUpdated, setWasUpdated] = useState<boolean | null>(null)
+
useEffect(() => {
mounted.current = true
@@ -85,6 +88,9 @@ export const CustomUserContextProvider = (props) => {
event === 'USER_UPDATED')
) {
setSession(session)
+ if (event === 'USER_UPDATED') {
+ setWasUpdated(true)
+ }
}
if (event === 'SIGNED_OUT') {
@@ -154,6 +160,7 @@ export const CustomUserContextProvider = (props) => {
error: null,
session: null,
user: null,
+ wasUpdated: null,
}
}
@@ -163,6 +170,7 @@ export const CustomUserContextProvider = (props) => {
error,
session: null,
user: null,
+ wasUpdated: null,
}
}
@@ -171,6 +179,7 @@ export const CustomUserContextProvider = (props) => {
error: null,
session: session,
user,
+ wasUpdated,
}
}, [isLoading, user, session, error])