Hey, usually the signOut flow just simply worked. I called two supertokens function at the frontend side (Next.js)
typescript
await EmailPasswordReact.signOut();
await EmailPasswordReact.redirectToAuth({ show: "signin" });
And it cleared all my cookies and redirected to the login page. It was pretty much it, but i noticed, that after i added a change password functionality to my site and after i successfully changed my password the EmailPasswordReact.signOut function call didn't cleared my cookies. I had to delete them manually then after a relogging, it worked just as before.
I checked my backend(Nest.js) code and it seems fine
typescript
@Post("/change-password")
@UseGuards(AuthGuard)
async changePassword(
@Session() session: SessionContainer,
@Body() changePasswordDto: ChangePasswordDto,
@Res() res: Response
) {
const { currentPassword, newPassword } = changePasswordDto;
const userId = session.getUserId();
const userInfo = await EmailPasswordNode.getUserById(userId);
if (userInfo === undefined) {
throw new Error("Should never come here");
}
const isPasswordValid = await EmailPasswordNode.signIn(userInfo.email, currentPassword);
if (isPasswordValid.status !== "OK") {
throw new BadRequestException("Hibás jelenlegi jelszó");
}
const response = await EmailPasswordNode.updateEmailOrPassword({
userId,
password: newPassword
}).catch((error) => {
console.log(error);
throw new InternalServerErrorException("Váratlan hiba");
});
if (response.status !== "OK") {
throw new InternalServerErrorException("Váratlan hiba");
}
await SupertokensSession.revokeAllSessionsForUser(userId);
await session.revokeSession();
return res.status(401);
}
Do you guys have any idea what i did wrong ?
Thanks for the answers in advance 🙂