NbAuthService

Common authentication service. Should be used to as an interlayer between UI Components and Auth Strategy.

Methods

NameDescription
authenticate()
parameters: strategyName: string, data: any
returns:Observable<NbAuthResult>

Authenticates with the selected strategy Stores received token in the token storage
Example: authenticate('email', {email: 'email@example.com', password: 'test'})

getStrategy()
parameters: strategyName: string
returns:NbAuthStrategy

Get registered strategy by name
Example: getStrategy('email')

getToken()
returns:Observable<NbAuthToken>

Retrieves current authenticated token stored

isAuthenticated()
returns:Observable<boolean>

Returns true if auth token is present in the token storage

isAuthenticatedOrRefresh()
returns:Observable<boolean>

Returns true if valid auth token is present in the token storage. If not, calls the strategy refreshToken, and returns isAuthenticated() if success, false otherwise

logout()
parameters: strategyName: string
returns:Observable<NbAuthResult>

Sign outs with the selected strategy Removes token from the token storage
Example: logout('email')

onAuthenticationChange()
returns:Observable<boolean>

Returns authentication status stream

onTokenChange()
returns:Observable<NbAuthToken>

Returns tokens stream

refreshToken()
parameters: strategyName: string, data: any
returns:Observable<NbAuthResult>

Sends a refresh token request Stores received token in the token storage
Example: refreshToken('email', {token: token})

register()
parameters: strategyName: string, data: any
returns:Observable<NbAuthResult>

Registers with the selected strategy Stores received token in the token storage
Example: register('email', {email: 'email@example.com', name: 'Some Name', password: 'test'})

requestPassword()
parameters: strategyName: string, data: any
returns:Observable<NbAuthResult>

Sends forgot password request to the selected strategy
Example: requestPassword('email', {email: 'email@example.com'})

resetPassword()
parameters: strategyName: string, data: any
returns:Observable<NbAuthResult>

Tries to reset password with the selected strategy
Example: resetPassword('email', {newPassword: 'test'})

Firebase Authentication
Previous page
NbPasswordAuthStrategy
Next page

Need some help or found an issue?

Ask on Stack Overflow with tag `nebular` or post an issue on GitHub.