login_functions.php
Table of Contents
Functions
- perform_login() : array<string|int, mixed>
- Performs the login using the global $username, and $password. Since the "externalauth" hook is allowed to change the credentials later on, the $password_hash needs to be global as well.
- generate_session_hash() : string
- Generates a unique session hash for user authentication.
- set_login_cookies() : void
- Set login cookies
- rs_password_hash() : string|false
- ResourceSpace password hashing
- rs_password_verify() : bool
- ResourceSpace verify password
- get_password_hash_info() : array<string|int, mixed>
- Helper function to get the password hash information (algorithm and options) from the global scope.
Functions
perform_login()
Performs the login using the global $username, and $password. Since the "externalauth" hook is allowed to change the credentials later on, the $password_hash needs to be global as well.
perform_login([mixed $loginuser = "" ][, mixed $loginpass = "" ]) : array<string|int, mixed>
Parameters
- $loginuser : mixed = ""
- $loginpass : mixed = ""
Return values
array<string|int, mixed> —Containing the login details ('valid' determines whether or not the login succeeded).
generate_session_hash()
Generates a unique session hash for user authentication.
generate_session_hash(string $password_hash) : string
This function creates a session hash based on either a completely randomized method or a method that combines a password hash with the current date. It ensures that the generated hash is unique by checking against existing sessions in the database.
Parameters
- $password_hash : string
-
The hashed password of the user, used for generating the session hash.
Return values
string —Returns a unique session hash.
set_login_cookies()
Set login cookies
set_login_cookies(int $user, string $session_hash[, string $language = "" ][, bool $user_preferences = true ]) : void
Parameters
- $user : int
-
User ref
- $session_hash : string
-
User session hash
- $language : string = ""
-
Language code (e.g en)
- $user_preferences : bool = true
-
Set colour theme from user preferences
rs_password_hash()
ResourceSpace password hashing
rs_password_hash(string $password) : string|false
Parameters
- $password : string
-
Password
Tags
Return values
string|false —Password hash or false on failure
rs_password_verify()
ResourceSpace verify password
rs_password_verify(string $password, string $hash, array<string|int, mixed> $data) : bool
Parameters
- $password : string
-
Password
- $hash : string
-
Password hash
- $data : array<string|int, mixed>
-
Extra data required for matching hash expectations (e.g username, impersonate_user). Key is the variable name, value is the actual value for that variable.
Return values
boolget_password_hash_info()
Helper function to get the password hash information (algorithm and options) from the global scope.
get_password_hash_info() : array<string|int, mixed>