Multiple User Types

An array of UserType can be passed in AngularTokenOptions at the root module with.forRoot(). The user type is selected during sign in and persists until sign out. .currentUserType() returns the currently logged in user.

Example:

this.tokenService.init({
  userTypes: [
    { name: 'ADMIN', path: 'admin' },
    { name: 'USER', path: 'user' }
  ]
});

this.tokenService.signIn({
  login:    'example@example.com',
  password: 'secretPassword',
  userType: 'ADMIN'
})

this.tokenService.currentUserType; // ADMIN

Showing/Hiding Elements based on UserType

When wanting to show or hide certain elements based on the UserRole, the following directive can be used as guideline.

Example:

Last updated

Was this helpful?