Class: CreateDefaultUserService
initialization/create-default-user.service.CreateDefaultUserService
Service for creating a new default user according to the environment config
Constructors
constructor
• new CreateDefaultUserService(strategiesService
, strategyInstanceService
, loginUserService
, userLoginDataService
, backendUserService
)
Parameters
Name | Type |
---|---|
strategiesService | StrategiesService |
strategyInstanceService | StrategyInstanceService |
loginUserService | LoginUserService |
userLoginDataService | UserLoginDataService |
backendUserService | BackendUserService |
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:18
Properties
backendUserService
• Private
Readonly
backendUserService: BackendUserService
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:23
logger
• Private
Readonly
logger: Logger
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:17
loginUserService
• Private
Readonly
loginUserService: LoginUserService
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:21
strategiesService
• Private
Readonly
strategiesService: StrategiesService
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:19
strategyInstanceService
• Private
Readonly
strategyInstanceService: StrategyInstanceService
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:20
userLoginDataService
• Private
Readonly
userLoginDataService: UserLoginDataService
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:22
Methods
createAndOrLinkUserAndLoginData
▸ Private
createAndOrLinkUserAndLoginData(user
, loginData
, username
, displayName
): Promise
<UserLoginData
>
Takes an optional user that the given loginData is to be linked to.
Possible cases:
- LoginData already has a user that differs from the given one => Error will be thrown
- LoginData has same user as given one => nothing is done
- LoginData has no user, user is given => LoginData is linked to given user
- LoginData has no user, no user is given => New user created and loginData linked to it
Parameters
Name | Type | Description |
---|---|---|
user | LoginUser | The existing user to link to the login data or undefined/null if one should be created |
loginData | UserLoginData | The login data that should be linked to the user given |
username | string | The username for a user to create |
displayName | string | The display name for a user to create |
Returns
Promise
<UserLoginData
>
the given loginData object, with link added
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:110
createDefaultUser
▸ createDefaultUser(): Promise
<void
>
Create a new default user if environment config is set that way.
A user will be created, if at least GROPIUS_DEFAULT_USER_USERNAME, GROPIUS_DEFAULT_USER_DISPLAYNAME and GROPIUS_DEFAULT_USER_STRATEGY_INSTANCE_NAME are set.
The system will be searched for matchin users in username and login data
Returns
Promise
<void
>
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:145
findStrategyAndInstance
▸ Private
findStrategyAndInstance(strategyInstanceName
): Promise
<{ strategy
: Strategy
; strategyInstance
: StrategyInstance
}>
Tries to find a login strategy instance with the given name. If none exists, tries to find one with the instance name field being interpreted as strategy type
Parameters
Name | Type | Description |
---|---|---|
strategyInstanceName | string | The name of the strategy instance or if that doesnt exist the strategy type to be retrieved |
Returns
Promise
<{ strategy
: Strategy
; strategyInstance
: StrategyInstance
}>
The strategy and strategy instance for the instance with the given name
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:34
getLoginDataThroughAuth
▸ Private
getLoginDataThroughAuth(strategyInstanceName
, postBody
): Promise
<UserLoginData
>
Executes the authentication using the strategy withthe provided name. If loginData is found it is returned. If none is found a new instance will be created and returned (UNSAVED!)
Parameters
Name | Type | Description |
---|---|---|
strategyInstanceName | string | The name of the strategy instance to use for authentication |
postBody | any | The body data to be "posted" to the strategy for authentication (e.g. password) |
Returns
Promise
<UserLoginData
>
Login data either retrieved by the auth or newly created
Defined in
gropius-login-service/backend/src/initialization/create-default-user.service.ts:67