Is there a way for me to run a custom function after the user successfully logs in?
I know i can have a custom redirect, like this: redirectTo: ‘/app/products’ and maybe add some value to the url like redirectTo: ‘/app/products?key=value’,
but i want to generate a token in my local client react app, after a successful login, and store the state in localstorage, the value in the state will be from
My current code:
import auth0 from "../../utils/auth0";
export default async function login(req, res){
try{
await auth0.handleLogin(req, res, {
getState: (req) => {
return {
somevalue: 123,
redirectTo: '/app/products'
}
}
runCustomFunctionHere() // this function should run after a successful login
});
// {
// Authorization: `Bearer ${token}`
// }
} catch(error){
console.log('error: ', error);
res.status(error.status || 400 ).end(error.message)
}
}
or is this something i can do in callback?
My env:
NodeJS 14
React Next JS for SSR