$k. User

new User(userInstance)

Constructs a user from the user instance

Parameters:
NameTypeDescription
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.

Parameters:
NameTypeDescription
namestring

The account name of the new user

Throws:

If new users cannot be created in this context.

Type
$k.exception.AccessDenied
Returns:

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
Returns:

The authenticated used, or undefined

Type: 
$k.User

(static) userAccount() → {$k.User}

Finds the user with the given account

Since
  • 5.4.0
Returns:

The user, or undefined if no such user exists

Type: 
$k.User

accountName() → {string}

Returns the name of the account

Since
  • 5.4.0
Returns:

The name, or undefined if there is no account

Type: 
string

changePassword(oldPassword, newPassword) → {boolean}

Changes the current users password

Parameters:
NameTypeDescription
oldPasswordstring

The old password to be verified

newPasswordstring

The new password to set

Throws:
Returns:

Return true if the password change was successful

Type: 
boolean
Example
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

Returns:
Type: 
$k.Instance

isAdmin() → {boolean}

Returns true if the user has administration rights

Since
  • 5.3.0
Returns:
Type: 
boolean

name() → {string}

Returns the name of the user

Overrides
Returns:

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

Parameters:
NameTypeDescription
passwordstring
Since
  • 5.4.0
Throws:

setInstance(instance)

Sets the instance associated with the user

Parameters:
NameTypeDescription
instance$k.Instance
Since
  • 5.4.0
Throws:

setInstancePassword(password)

Sets the password of the user instance

Parameters:
NameTypeDescription
passwordstring
Since
  • 5.4.0
Throws:

setIsAdmin(enable)

Enable/disable permanent administration rights

Parameters:
NameTypeDescription
enableboolean
Since
  • 5.4.0
Throws:

$k. User

new User()

Extends

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.

Parameters:
NameTypeDescription
namestring

The account name of the new user

Throws:

If new users cannot be created in this context.

Type
$k.exception.AccessDenied
Returns:

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
Returns:

The authenticated used, or undefined

Type: 
$k.User

(static) userAccount() → {$k.User}

Finds the user with the given account

Since
  • 5.4.0
Returns:

The user, or undefined if no such user exists

Type: 
$k.User

accountName() → {string}

Returns the name of the account

Since
  • 5.4.0
Returns:

The name, or undefined if there is no account

Type: 
string

changePassword(oldPassword, newPassword) → {boolean}

Changes the current users password

Parameters:
NameTypeDescription
oldPasswordstring

The old password to be verified

newPasswordstring

The new password to set

Throws:
Returns:

Return true if the password change was successful

Type: 
boolean
Example
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

Returns:
Type: 
$k.Instance

isAdmin() → {boolean}

Returns true if the user has administration rights

Since
  • 5.3.0
Returns:
Type: 
boolean

name() → {string}

Returns the name of the user

Overrides
Returns:

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

Parameters:
NameTypeDescription
passwordstring
Since
  • 5.4.0
Throws:

setInstance(instance)

Sets the instance associated with the user

Parameters:
NameTypeDescription
instance$k.Instance
Since
  • 5.4.0
Throws:

setInstancePassword(password)

Sets the password of the user instance

Parameters:
NameTypeDescription
passwordstring
Since
  • 5.4.0
Throws:

setIsAdmin(enable)

Enable/disable permanent administration rights

Parameters:
NameTypeDescription
enableboolean
Since
  • 5.4.0
Throws:

$k. User

new User()

Extends

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.

Parameters:
NameTypeDescription
namestring

The account name of the new user

Throws:

If new users cannot be created in this context.

Type
$k.exception.AccessDenied
Returns:

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
Returns:

The authenticated used, or undefined

Type: 
$k.User

(static) userAccount() → {$k.User}

Finds the user with the given account

Since
  • 5.4.0
Returns:

The user, or undefined if no such user exists

Type: 
$k.User

accountName() → {string}

Returns the name of the account

Since
  • 5.4.0
Returns:

The name, or undefined if there is no account

Type: 
string

changePassword(oldPassword, newPassword) → {boolean}

Changes the current users password

Parameters:
NameTypeDescription
oldPasswordstring

The old password to be verified

newPasswordstring

The new password to set

Throws:
Returns:

Return true if the password change was successful

Type: 
boolean
Example
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

Returns:
Type: 
$k.Instance

isAdmin() → {boolean}

Returns true if the user has administration rights

Since
  • 5.3.0
Returns:
Type: 
boolean

name() → {string}

Returns the name of the user

Overrides
Returns:

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

Parameters:
NameTypeDescription
passwordstring
Since
  • 5.4.0
Throws:

setInstance(instance)

Sets the instance associated with the user

Parameters:
NameTypeDescription
instance$k.Instance
Since
  • 5.4.0
Throws:

setInstancePassword(password)

Sets the password of the user instance

Parameters:
NameTypeDescription
passwordstring
Since
  • 5.4.0
Throws:

setIsAdmin(enable)

Enable/disable permanent administration rights

Parameters:
NameTypeDescription
enableboolean
Since
  • 5.4.0
Throws: