Hello!!! folloing this Example Express + Vue js
I’m trying to implement in my back one service that redirect the user to default page if the user is invalid(email) or if the users is blocked, so in my back I added this function:
export const saveSession = async (req, res, next) => {
try {
const { email, username } = req.body;
const UserUnauthorized = await authenticationService.validateUser(email);
//check if user is blocked
//if UserUnauthorized == true, the user is blocked
//if UserUnauthorized == null, the user cannot access the system
if( UserUnauthorized || UserUnauthorized === null ){
req.logout();
res.redirect(`https://${env.AUTH0_DOMAIN}/v2/logout?returnTo=${env.CLIENT_ORIGIN_URL}`);
}else{
//if not blocked, then save session
req.session.user = { username , email };
res.status(200).send("Data Saved");
}
} catch (error) {
next(error);
}
};
currently don’t work, so I would like your help, How can I destroy the auth0 session and redirect to a default page???