JUserHelper
Authorisation helper class, provides static methods to perform various tasks relevant to the Joomla user and authorisation classes
This class has influences and some method logic from the Horde Auth package
package |
Joomla.Platform |
---|---|
subpackage |
User |
since |
11.1 |
Methods
_bin
Converts hexadecimal string to binary data.
_bin(string $hex) : string
since |
11.1 |
---|
Arguments
- $hex
string
Hex data.
Response
string
Binary data.
_toAPRMD5
Converts to allowed 64 characters for APRMD5 passwords.
_toAPRMD5(string $value, integer $count) : string
since |
11.1 |
---|
Arguments
- $value
string
The value to convert.- $count
integer
The number of characters to convert.
Response
string
$value converted to the 64 MD5 characters.
activateUser
Method to activate a user
activateUser(string $activation) : boolean
since |
11.1 |
---|
Arguments
- $activation
string
Activation string
Response
boolean
True on success
addUserToGroup
Method to add a user to a group.
addUserToGroup(integer $userId, integer $groupId) : mixed
since |
11.1 |
---|
Arguments
- $userId
integer
The id of the user.- $groupId
integer
The id of the group.
Response
mixed
Boolean true on success, Exception on error.
genRandomPassword
Generate a random password
genRandomPassword(integer $length = 8) : string
since |
11.1 |
---|
Arguments
- $length
integer
Length of the password to generate
Response
string
Random Password
getCryptedPassword
Formats a password using the current encryption.
getCryptedPassword(string $plaintext, string $salt = '', string $encryption = 'md5-hex', boolean $show_encrypt = false) : string
since |
11.1 |
---|---|
deprecated |
4.0 |
Arguments
- $plaintext
string
The plaintext password to encrypt.- $salt
string
The salt to use to encrypt the password. [] If not present, a new salt will be generated.- $encryption
string
The kind of password encryption to use. Defaults to md5-hex.- $show_encrypt
boolean
Some password systems prepend the kind of encryption to the crypted password ({SHA}, etc). Defaults to false.
Response
string
The encrypted password.
getProfile
Gets the user profile information
getProfile(integer $userId) : object
since |
11.1 |
---|
Arguments
- $userId
integer
The id of the user.
Response
object
getSalt
Returns a salt for the appropriate kind of password encryption.
getSalt(string $encryption = 'md5-hex', string $seed = '', string $plaintext = '') : string
Optionally takes a seed and a plaintext password, to extract the seed of an existing password, or for encryption types that use the plaintext in the generation of the salt.
since |
11.1 |
---|
Arguments
- $encryption
string
The kind of password encryption to use. Defaults to md5-hex.- $seed
string
The seed to get the salt from (probably a previously generated password). Defaults to generating a new seed.- $plaintext
string
The plaintext password that we're generating a salt for. Defaults to none.
Response
string
The generated or extracted salt.
getUserGroups
Method to get a list of groups a user is in.
getUserGroups(integer $userId) : mixed
since |
11.1 |
---|
Arguments
- $userId
integer
The id of the user.
Response
mixed
Array on success, JException on error.
getUserId
Returns userid if a user exists
getUserId(string $username) : integer
since |
11.1 |
---|
Arguments
- $username
string
The username to search on.
Response
integer
The user id or 0 if not found.
hashPassword
Hashes a password using the current encryption.
hashPassword(string $password) : string
since |
3.2.1 |
---|
Arguments
- $password
string
The plaintext password to encrypt.
Response
string
The encrypted password.
removeUserFromGroup
Method to remove a user from a group.
removeUserFromGroup(integer $userId, integer $groupId) : mixed
since |
11.1 |
---|
Arguments
- $userId
integer
The id of the user.- $groupId
integer
The id of the group.
Response
mixed
Boolean true on success, JException on error.
setUserGroups
Method to set the groups for a user.
setUserGroups(integer $userId, array $groups) : mixed
since |
11.1 |
---|
Arguments
- $userId
integer
The id of the user.- $groups
array
An array of group ids to put the user in.
Response
mixed
Boolean true on success, Exception on error.
verifyPassword
Formats a password using the current encryption. If the user ID is given and the hash does not fit the current hashing algorithm, it automatically updates the hash.
verifyPassword(string $password, string $hash, integer $user_id) : boolean
since |
3.2.1 |
---|
Arguments
- $password
string
The plaintext password to check.- $hash
string
The hash to verify against.- $user_id
integer
ID of the user if the password hash should be updated
Response
boolean
True if the password and hash match, false otherwise