Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JwtService

This service class manages the JWT authentication, the session and the current login state.

Hierarchy

  • JwtService

Implements

Index

Constructors

constructor

Properties

Protected _repository

_repository: BaseRepository

the Repository reference for the Authentication. The service will read its configuration and use its HttpProvider

Protected _stateSubject

_stateSubject: BehaviorSubject<LoginState> = new BehaviorSubject<LoginState>(LoginState.Pending)

The private subject for tracking the login state

Accessors

CurrentState

CurrentUser

  • get CurrentUser(): string
  • Returns the current user's name as a string. In case of unauthenticated users, it will return 'BuiltIn\Visitor'

    Returns string

State

Methods

CheckForUpdate

  • CheckForUpdate(): Observable<boolean>
  • Executed before each Ajax call. If the access token has been expired, but the refresh token is still valid, it triggers the token refreshing call

    Returns Observable<boolean>

    An observable with a variable that indicates if there was a refresh triggered.

GetOauthProvider

  • GetOauthProvider<T>(providerType: object): T

HandleAuthenticationResponse

Login

  • Login(username: string, password: string): Observable<boolean>
  • It is possible to send authentication requests using this action. You provide the username and password and will get the User object as the response if the login operation was successful or HTTP 403 Forbidden message if it wasn’t. If the username does not contain a domain prefix, the configured default domain will be used. After you logged in the user successfully, you will receive a standard ASP.NET auth cookie which will make sure that your subsequent requests will be authorized correctly.

    The username and password is sent in clear text, always send these kinds of requests through HTTPS.

    Parameters

    • username: string

      Name of the user.

    • password: string

      Password of the user.

    Returns Observable<boolean>

    Returns an RxJS observable that you can subscribe of in your code.

    let userLogin = service.Login('alba', 'alba');
    userLogin.subscribe({
     next: response => {
         console.log('Login success', response);
     },
     error: error => console.error('something wrong occurred: ' + error.responseJSON.error.message.value),
     complete: () => console.log('done'),
    });
    

Logout

  • Logout(): Observable<boolean>

SetOauthProvider

  • SetOauthProvider<T>(provider: T): void

Generated using TypeDoc