File

core/login/login.service.ts

Description

Service to manage the login.

Index

Properties
Methods

Constructor

constructor(injector: Injector, client: FetchClient, basicAuth: BasicAuth, cookieAuth: CookieAuth, ui: AppStateService, user: UserService, tenant: TenantService, realtime: Realtime, alert: AlertService, api: ApiService, tenantUiService: TenantUiService, tenantLoginOptionsService: TenantLoginOptionsService, translateService: TranslateService, location: LocationStrategy)
Parameters :
Name Type Optional
injector Injector No
client FetchClient No
basicAuth BasicAuth No
cookieAuth CookieAuth No
ui AppStateService No
user UserService No
tenant TenantService No
realtime Realtime No
alert AlertService No
api ApiService No
tenantUiService TenantUiService No
tenantLoginOptionsService TenantLoginOptionsService No
translateService TranslateService No
location LocationStrategy No

Methods

addSuccessMessage
addSuccessMessage(successKey: string)

Adds a new success message

Parameters :
Name Type Optional Description
successKey string No

The key of the success message as used in SUCCESS_MESSAGES

Returns : void
Async authFulfilled
authFulfilled(tenant?, user?, supportUserName?)

Saves tenant, user and support user info to the app state.

Parameters :
Name Optional Description
tenant Yes

The current tenant object.

user Yes

The current user object.

supportUserName Yes

The current support user name.

Returns : any
autoLogout
autoLogout()
Returns : void
cleanMessages
cleanMessages()

Clears all backend errors.

Returns : void
Async generateOauthToken
generateOauthToken(credentials?: ICredentials)
Parameters :
Name Type Optional
credentials ICredentials Yes
Returns : unknown
getAuthStrategy
getAuthStrategy()

Returns the current strategy. Defaults to cookie, if a token is found in local or session storage we switch to basic auth.

Returns : IAuthentication

The current auth strategy.

Async getEnforcePasswordStrength
getEnforcePasswordStrength(refresh?)

Checks if password strength is enforced for system by retrieving value of enforceStrength property from loginOptions response If false, it takes value from memory, if true, it refresh the app state value and then retrives data.

Parameters :
Name Optional Description
refresh Yes

boolean used to refresh the app state where result of loginOptions response is stored. If false, it takes value from memory, if true, it refresh the app state value and then retrives data.

Returns : unknown

boolean value, true if enforced, false otherwise.

Async getGreenMinLength
getGreenMinLength()

Gets the minimal number of characters that a password should have to be considered a “green” strong one.

Returns : unknown

The min length for password or default value.

Async getPasswordStrengthEnforced
getPasswordStrengthEnforced(options?)

Function determines if enforced strength checks should be enabled for current tenant based on properties retrieved from loginOptions

  • {refresh: true} - refreshes values of app state and returns fresh values as result of call
Parameters :
Name Optional Description
options Yes

object containing specific options:

  • {refresh: true} - refreshes values of app state and returns fresh values as result of call
Returns : unknown

boolean value, true if strength is enforced for tenant, false otherwise.

Async getPasswordStrengthValidity
getPasswordStrengthValidity(refresh?)

Checks if password strength is enforced for particular tenant by retrieving value of strengthValidity property from loginOptions response If false, it takes value from memory, if true, it refresh the app state value and then retrives data.

Parameters :
Name Optional Description
refresh Yes

boolean used to refresh the app state where result of loginOptions response is stored. If false, it takes value from memory, if true, it refresh the app state value and then retrives data.

Returns : unknown

boolean value, true if enforced, false otherwise.

getTenant
getTenant()

Returns the current tenant.

Returns : any

The tenant name.

initLoginOptions
initLoginOptions()
Returns : void
Async isPasswordGrantLogin
isPasswordGrantLogin(credentials?: ICredentials)
Parameters :
Name Type Optional
credentials ICredentials Yes
Returns : unknown
isSupportUser
isSupportUser(credentials?: ICredentials)

Verifies if the provided credentials use a support user to log in or not.

Parameters :
Name Type Optional Description
credentials ICredentials Yes

Credentials to check.

Returns : boolean

Returns true if user is a support user.

Async login
login(auth: IAuthentication, credentials?: ICredentials)

Tries to login a user with the given credentials. If successful, the current tenant and user is set. If not an error is thrown. It also verifies if the user is allowed to open the current app.

Parameters :
Name Type Optional Default value Description
auth IAuthentication No this.getAuthStrategy()

The authentication strategy used.

credentials ICredentials Yes

The credentials to try to login.

Returns : any
Async logout
logout(reload)

Logs the user out

Parameters :
Name Optional Default value Description
reload No true

If set to false, the page will not reload

Returns : any
redirectToDomain
redirectToDomain(domain)
Parameters :
Name Optional
domain No
Returns : void
redirectToOauth
redirectToOauth()
Returns : void
Async reset
reset()

Resets the stored auth-data

Returns : unknown
saveTFAToken
saveTFAToken(tfaToken: string, storage: Storage)

Saves the TFA token to local or session storage.

Parameters :
Name Type Optional Description
tfaToken string No

The tfa token to save.

storage Storage No

The storage to use (local or session).

Returns : void
showTenant
showTenant()

Verifies if the tenant input field should be shown or not.

Returns : boolean

If true, show the tenant input.

showTenantSetup
showTenantSetup()

Verifies if the tenant setup should be shown or not.

Returns : boolean

If true, show the tenant input.

Async switchLoginMode
switchLoginMode(credentials?: ICredentials)

Switch the login mode to CookieAuth if the user has configured to use it in loginOptions.

Parameters :
Name Type Optional Description
credentials ICredentials Yes

The credentials for that login

Returns : unknown
useBasicAuth
useBasicAuth(credentials: ICredentials)

Forces the use of basic auth as strategy with this credentials.

Parameters :
Name Type Optional Description
credentials ICredentials No

The credentials to use.

Returns : BasicAuth
Async verifyAppAccess
verifyAppAccess()

Request the manifest -> on 401 user has no access to that application and we throw the error up to the login form.

Returns : any

Properties

ERROR_MESSAGES
Type : object
Default value : { minlength: gettext('Password must have at least 8 characters and no more than 32.'), password_missmatch: gettext('Password confirmation does not match.'), maxlength: gettext('Password must have at least 8 characters and no more than 32.'), password_strength: gettext( 'Your password is not strong enough. Please include numbers, lower and upper case characters' ), remote_error: gettext('Server error occurred.'), email: gettext('Invalid email address.'), password_change: gettext('Your password is expired. Please set a new password.'), password_reset_token_expired: gettext( 'Password reset link expired. Please enter your email address to receive a new one.' ), tfa_pin_invalid: gettext('The code you entered is invalid. Please try again.'), pattern_newPassword: this.translateService.instant( gettext( 'Password must have at least 8 characters and no more than 32 and can only contain letters, numbers and following symbols: {{ symbols }}' ), { symbols: '`~!@#$%^&*()_|+-=?;:\'",.<>{}[]\\/' } ), internationalPhoneNumber: gettext( 'Must be a valid phone number (only digits, spaces, slashes ("/"), dashes ("-"), and plus ("+") allowed, for example: +49 9 876 543 210).' ), phone_number_error: gettext('Could not update phone number.'), pinAlreadySent: gettext( 'The verification code was already sent. For a new verification code, please click on the link above.' ), passwordConfirm: gettext('Password confirmation does not match.'), tfaExpired: gettext('Two-factor authentication token expired.') }
GREEN_MIN_LENGTH_DEFAULT
Type : number
Default value : 8
isFirstLogin
Default value : true
loginMode
Type : ITenantLoginOption
managementLoginMode
Type : ITenantLoginOption
oauthOptions
Type : ITenantLoginOption
rememberMe
Default value : false
TFATOKEN_KEY
Type : string
Default value : 'TFAToken'
TOKEN_KEY
Type : string
Default value : '_tcy8'

results matching ""

    No results matching ""