new User(userInstance)
Constructs a user from the user instance
Name | Type | Description |
---|---|---|
userInstance | $k.Instance | User instance Represents a user. |
Methods
(static) createUserAccount(name) → {$k.User}
Creates a new user account.
Currently, the active user must have administration rights. Note: Elevating the context with elevatedDo() does not grant administration rights.
Name | Type | Description |
---|---|---|
name | string | The account name of the new user |
If new users cannot be created in this context.
The new user
- Type:
- $k.User
(static) getAuthenticatedUser() → {$k.User}
Finds, authenticates and returns the user. Returns undefined if thre is either no such user, or if the password does not match.
Requires a transaction.
- Version
- Experimental feature, might be removed at any time
- Since
- 5.0.1
The authenticated used, or undefined
- Type:
- $k.User
(static) userAccount() → {$k.User}
Finds the user with the given account
- Since
- 5.4.0
The user, or undefined if no such user exists
- Type:
- $k.User
accountName() → {string}
Returns the name of the account
- Since
- 5.4.0
- Overrides
The name, or undefined if there is no account
- Type:
- string
changePassword(oldPassword, newPassword) → {boolean}
Changes the current users password
Name | Type | Description |
---|---|---|
oldPassword | string | The old password to be verified |
newPassword | string | The new password to set |
- Overrides
If the user object and transaction-user mismatch
If one of the provided passwords is undefined/null
If there is no current user set or no password attribute available
Return true if the password change was successful
- Type:
- boolean
try { result = $k.user().changePassword("oldsecret", "newsecret") }
catch(e) { error = e.toString() }
instance() → {$k.Instance}
Returns the instance associated with the user, or undefined if there is none
- Overrides
- Type:
- $k.Instance
isAdmin() → {boolean}
Returns true if the user has administration rights
- Since
- 5.3.0
- Overrides
- Type:
- boolean
name() → {string}
Returns the name of the user
- Overrides
The name of the user instance, or the name of the account if there is no associated instance
- Type:
- string
setAccountPassword(password)
Sets the password of the user account
Name | Type | Description |
---|---|---|
password | string |
- Since
- 5.4.0
- Overrides
If the user cannot be modified in this context
If the user has no user account
setInstance(instance)
Sets the instance associated with the user
Name | Type | Description |
---|---|---|
instance | $k.Instance |
- Since
- 5.4.0
- Overrides
If the user cannot be modified in this context
If the user has no user account
setInstancePassword(password)
Sets the password of the user instance
Name | Type | Description |
---|---|---|
password | string |
- Since
- 5.4.0
- Overrides
If the user cannot be modified in this context
If the user has no user instance
setIsAdmin(enable)
Enable/disable permanent administration rights
Name | Type | Description |
---|---|---|
enable | boolean |
- Since
- 5.4.0
- Overrides
If the user cannot be modified in this context
If the user has no user account