Module connection

January 9, 2025 · View on GitHub

category:public

Source file

Class Connection

Provides an encapsulation of the OpenID Connect user connection.

Constructors

Connection(router, configuration, userManager, userPrompt)

Creates an instance of the class with the given parameter.

ParametersTypeDescription
routerRouterthe aurelia router
configurationPluginConfigurationthe openid plugin configuration
userManagerUserManagerthe openid user manager
userPromptUserPromptthe user prompt to confirm reconnection

Methods

observeUser(userfunc) ► Promise.<void>

modifier: public

Defines a callback called when user connection changes.

ParametersTypeDescription
userfunc(user: User) => voida callback called when user connection changes
returnPromise.<void>the promise that retrieves user

getUser() ► Promise.<User>

modifier: public

Retrieves the connected user.

ParametersTypeDescription
returnPromise.<User>the connected user

loginUser(route, options) ► Promise.<void>

modifier: public

Initiates the OpenID Connect user connection.

ParametersTypeDescription
routestringthe aurelia route name to be redirected after login - if not specified this will be the current route
optionsExtraSigninRequestArgsoptional options passed to underlying oidc signin method
returnPromise.<void>**

logoutUser(route, options) ► Promise.<void>

modifier: public

Initiates the OpenID Connect user deconnection.

ParametersTypeDescription
routestringthe aurelia route name to be redirected after logout - if not specified this will be the current route
optionsExtraSignoutRequestArgsoptional options passed to underlying oidc signout method
returnPromise.<void>**

trySilentLogin(route) ► Promise.<void>

modifier: public

Initiates the OpenID Connect silent user connection and displays the reconnect prompt if asked by the provider.

ParametersTypeDescription
routestringthe aurelia route name to be redirected in case of reconnnect prompt - if not specified this will be the current route
returnPromise.<void>**

_setUser(user)

modifier: private

Sets the connected user entity.

ParametersTypeDescription
userUserthe OpenID Connect user

Members

NameTypeDescription
inProgressbooleanIs silent login in progress?
userIdstringThe user identifier. It may be undefined.
isUserLoggedInbooleanIs the user currently connected with an eventually expired access token?
hasValidAccessTokenbooleanHas the user a valid access token?
accessTokenstringThe user access token. The token may be expired. Check hasValidAccessToken property before.
userNamestringThe display name of the user. The 'name' claim is used to provide this information.
profileUserProfileThe profile of the user. It contains the claims provided by the identity provider.
expiresInnumberThe number of seconds the access token has remaining.