PHP Class Airship\Cabin\Bridge\Blueprint\UserAccounts

Manage user accounts
Inheritance: extends BlueprintGear, use trait SecurityBolt
Show file Open project: paragonie/airship Class Usage Examples

Public Methods

Method Description
countPublicUsers ( ) : integer Get the number of users with a public profile.
createGroup ( array $post = [] ) : boolean Create a new user group
createRecoveryToken ( integer $userID ) : string
createSessionCanary ( integer $userID ) : string
createUser ( array $post = [] ) : integer Create a new user account
deleteGroup ( integer $groupId, integer $newParent ) : boolean
deleteRecoveryToken ( string $selector ) : boolean
deleteUser ( integer $userId ) : boolean
editGroup ( integer $groupId, array $post = [] ) : boolean Edit a group.
editUser ( integer $userId, array $post = [] ) : boolean Edit a user's account information
editUserCustomFields ( integer $userId, string $customFields = '[]' ) : boolean Only change the custom fields.
getDirectory ( integer $offset, integer $limit = 20 ) : array Get the user directory.
getGroup ( integer $groupId ) : array
getGroupChildren ( integer $groupId ) : array Get all of the group IDs (not the contents) of a group's children
getGroupTree ( integer $parent, string $column = 'children', array $seen = [] ) : array Get the group tree
getRecoveryData ( string $selector, integer $maxTokenLife ) : array Get the data necessary to recover an account.
getRecoveryInfo ( string $username ) : array Get account recovery information
getTwoFactorSecret ( integer $userID ) : string Get the user's two-factor authentication secret
getUniqueId ( integer $userId ) : string Get a user's unique ID
getUserAccount ( integer $userId, boolean $includeExtra = false ) : array Get a user account given a user ID
getUserByUsername ( string $username, boolean $includeExtra = false ) : array Get a user account, given a username
getUserIDByUsername ( string $username ) : integer
getUserPreferences ( integer $userId ) : array Get a user's preferences
getUsersGroups ( integer $userId ) : array Get all the groups that a user belongs to.
invalidateLongTermAuthTokens ( integer $userID ) : boolean All long-term authentication tokens will be rendered invalid.
isPasswordWeak ( array $post ) : boolean Is this password too weak?
isUsernameInvalid ( string $username ) : boolean Is this username invalid? Currently not implemented but might be in the final version.
isUsernameTaken ( string $username ) : boolean Is the username already taken by another account?
listUsers ( integer $offset, integer $limit, string $sortBy = 'userid', string $dir = 'ASC' ) : array List users
numUsers ( ) : integer How many users exist?
resetTwoFactorSecret ( integer $userID ) : boolean Get the user's two-factor authentication secret
setPassphrase ( HiddenString $passphrase, integer $accountId ) : boolean Reset a user's passphrase
toggleTwoFactor ( integer $userID, array $post ) : boolean Save the user's two-factor-authentication preferences
updateAccountInfo ( array $post, array $account ) : mixed Update the user's account information
updatePreferences ( integer $userId, array $preferences = [] ) : boolean Store preferences for a user

Protected Methods

Method Description
deleteGroupCascade ( integer $groupId ) Overloadable in gadgets. Deletes all entries that depend on the group table.
deleteUserCascade ( integer $userId ) Overloadable in gadgets. Deletes all entries that depend on the user table.
generateUniqueId ( ) : string Generate a unique random public ID for this user, which is distinct from the username they use to log in.

Method Details

countPublicUsers() public method

Get the number of users with a public profile.
public countPublicUsers ( ) : integer
return integer

createGroup() public method

Create a new user group
public createGroup ( array $post = [] ) : boolean
$post array
return boolean

createRecoveryToken() public method

public createRecoveryToken ( integer $userID ) : string
$userID integer
return string

createSessionCanary() public method

public createSessionCanary ( integer $userID ) : string
$userID integer
return string

createUser() public method

Create a new user account
public createUser ( array $post = [] ) : integer
$post array
return integer

deleteGroup() public method

public deleteGroup ( integer $groupId, integer $newParent ) : boolean
$groupId integer
$newParent integer
return boolean

deleteGroupCascade() protected method

Overloadable in gadgets. Deletes all entries that depend on the group table.
protected deleteGroupCascade ( integer $groupId )
$groupId integer

deleteRecoveryToken() public method

public deleteRecoveryToken ( string $selector ) : boolean
$selector string
return boolean

deleteUser() public method

public deleteUser ( integer $userId ) : boolean
$userId integer
return boolean

deleteUserCascade() protected method

Overloadable in gadgets. Deletes all entries that depend on the user table.
protected deleteUserCascade ( integer $userId )
$userId integer

editGroup() public method

Edit a group.
public editGroup ( integer $groupId, array $post = [] ) : boolean
$groupId integer
$post array
return boolean

editUser() public method

Edit a user's account information
public editUser ( integer $userId, array $post = [] ) : boolean
$userId integer
$post array
return boolean

editUserCustomFields() public method

Only change the custom fields.
public editUserCustomFields ( integer $userId, string $customFields = '[]' ) : boolean
$userId integer
$customFields string
return boolean

generateUniqueId() protected method

Generate a unique random public ID for this user, which is distinct from the username they use to log in.
protected generateUniqueId ( ) : string
return string

getDirectory() public method

Get the user directory.
public getDirectory ( integer $offset, integer $limit = 20 ) : array
$offset integer
$limit integer
return array

getGroup() public method

public getGroup ( integer $groupId ) : array
$groupId integer
return array

getGroupChildren() public method

Get all of the group IDs (not the contents) of a group's children
public getGroupChildren ( integer $groupId ) : array
$groupId integer
return array

getGroupTree() public method

Get the group tree
public getGroupTree ( integer $parent, string $column = 'children', array $seen = [] ) : array
$parent integer
$column string What to call the child element?
$seen array
return array

getRecoveryData() public method

Get the data necessary to recover an account.
public getRecoveryData ( string $selector, integer $maxTokenLife ) : array
$selector string
$maxTokenLife integer
return array

getRecoveryInfo() public method

Get account recovery information
public getRecoveryInfo ( string $username ) : array
$username string
return array

getTwoFactorSecret() public method

Get the user's two-factor authentication secret
public getTwoFactorSecret ( integer $userID ) : string
$userID integer
return string

getUniqueId() public method

Get a user's unique ID
public getUniqueId ( integer $userId ) : string
$userId integer
return string

getUserAccount() public method

Get a user account given a user ID
public getUserAccount ( integer $userId, boolean $includeExtra = false ) : array
$userId integer
$includeExtra boolean
return array

getUserByUsername() public method

Get a user account, given a username
public getUserByUsername ( string $username, boolean $includeExtra = false ) : array
$username string
$includeExtra boolean
return array

getUserIDByUsername() public method

public getUserIDByUsername ( string $username ) : integer
$username string
return integer

getUserPreferences() public method

Get a user's preferences
public getUserPreferences ( integer $userId ) : array
$userId integer
return array

getUsersGroups() public method

Get all the groups that a user belongs to.
public getUsersGroups ( integer $userId ) : array
$userId integer
return array

invalidateLongTermAuthTokens() public method

This is usually triggered on a password reset.
public invalidateLongTermAuthTokens ( integer $userID ) : boolean
$userID integer
return boolean

isPasswordWeak() public method

Is this password too weak?
public isPasswordWeak ( array $post ) : boolean
$post array
return boolean

isUsernameInvalid() public method

Is this username invalid? Currently not implemented but might be in the final version.
public isUsernameInvalid ( string $username ) : boolean
$username string
return boolean

isUsernameTaken() public method

Is the username already taken by another account?
public isUsernameTaken ( string $username ) : boolean
$username string
return boolean

listUsers() public method

List users
public listUsers ( integer $offset, integer $limit, string $sortBy = 'userid', string $dir = 'ASC' ) : array
$offset integer
$limit integer
$sortBy string
$dir string
return array

numUsers() public method

How many users exist?
public numUsers ( ) : integer
return integer

resetTwoFactorSecret() public method

Get the user's two-factor authentication secret
public resetTwoFactorSecret ( integer $userID ) : boolean
$userID integer
return boolean

setPassphrase() public method

Reset a user's passphrase
public setPassphrase ( HiddenString $passphrase, integer $accountId ) : boolean
$passphrase HiddenString
$accountId integer
return boolean

toggleTwoFactor() public method

Save the user's two-factor-authentication preferences
public toggleTwoFactor ( integer $userID, array $post ) : boolean
$userID integer
$post array
return boolean

updateAccountInfo() public method

Update the user's account information
public updateAccountInfo ( array $post, array $account ) : mixed
$post array
$account array
return mixed

updatePreferences() public method

Store preferences for a user
public updatePreferences ( integer $userId, array $preferences = [] ) : boolean
$userId integer
$preferences array
return boolean