a
NestJs and Vuejs Role route verification implentation from documentation is not working
r
hey @Alexxkr1 what's the issue that you are facing?
a

https://cdn.discordapp.com/attachments/1108326124808843335/1108328308510294086/image.png

Hey, this custom way is not working for me
r
can you tell me what error you are facing though? For example, whats the return value of
await session.getClaimValue(UserRoles.UserRoleClaim)
?
a
Okei im sorry, you can delete my message, yesterday i was doing and testing this thing for an 3 hours and it returned always empty array 😅
Now everything worked
r
Hmm okay.
a
@rp Hey, I was playinh around. Do i actually have to create the roles on every login or why because if i make the roles and then remove it. On next reload the roles are missing

https://cdn.discordapp.com/attachments/1108326124808843335/1109109672381788270/image.png

r
you need to create roles just one
once*
they get stored in your mysql / postgresql db
a

https://cdn.discordapp.com/attachments/1108326124808843335/1109459766348107816/image.png

Maybe i am doing something wrong these are empty aswell even when i logged in a user
r
Hmm. That’s strange
How did you login a user?
a
Copy code
@UsePipes(ValidationPipe)
  @Post('/sign-in')
  async signInUser(
    @Body() signInDto: SignInDto,
    @Res() res: Response,
    @Req() req: Request,
  ) {
    const { email, password } = signInDto;

    const userData = await this.authService.signIn(email, password);

    if (userData.status === 401) {
      return res.status(401).json({ error: userData.message });
    }
    await createNewSession(req, res, userData.id);
r
you should use the APIs we have for sign in instead of making your own APIs.
This is the thing?
How to force refresh, i am setting some roles in frontend but they are not appearing before user has logged out and logged in again
r
you are setting the roles in api override. Instead, you should set them in functions override. If you want to use api override that's fine, but you need to do
await response.session.fetchAndSetClaim(UserRoleClaim)
in your override where
resopnse
is the result of calling the original implementaiton. Our docs does mention this here: https://supertokens.com/docs/userroles/managing-roles-and-users
2 Views