AppRouterInstance.push doesn't do anything...
Unanswered
Satin Angora posted this in #help-forum
Satin AngoraOP
I have a sign-in flow where after I get OTP from user and verify it, I push a protected route. I think I tested all parts of the algorithm, but I can't push to a new route!
This is how I use
Could you give me some pointers as to help me solve this issue?
This is how I use
AppRouterInstance.push currently:const updateSignedUser = useCallback(async () => {
console.log("Called updateSignedUser. Updating current user-")
await updateCurrentUser(signedUser)
console.log("Updated current user: " + getCurrentUser()?.phoneNumber)
//router.refresh()
//console.log("Refreshed the route")
console.log(router)
router.push(getDashboardRoute(DashboardRoute.DashboardRoot).url)
console.log("Pushed new route!")
}, [router, signedUser])
useEffect(() => {
if (signedUser !== null) {
console.log("There is a user! > " + signedUser.phoneNumber)
updateSignedUser()
}
}, [signedUser, updateSignedUser])
...
async function verifySMSCode(formData: FormData) {
const submittedCode = getEntriesAsMapFrom(formData)[fieldVerfCode.name]
try {
const phoneAuthCreds = getCredentials(confirmationResult, submittedCode)
const userCreds = await signInWithCred(phoneAuthCreds)
console.log("signInWithCred has been called. userCreds is: "+userCreds.user.phoneNumber)
setSignedUser(userCreds.user)
} catch (e) {... I hit all logs, and I get a non-null user instance with right credentials... I tried calling push directly, calling it inside an effect, using it inside callback, refreshing the route (before and after the push)... Nothing works! I only get some CSS prefetch related warning in the browser console...Could you give me some pointers as to help me solve this issue?
2 Replies
Satin AngoraOP
My current route stack is as following;
app/
[lang]/
dashboard/
page.tsx
login/
page.tsx Could it be because that the route I'm trying to push is behind (is this terminology event right?) my current route? I'm trying to push from .../dashboard/login to .../dashboardSatin AngoraOP
I can push to the root route...