z_loginModel
extends z_model
in package
The login model holds logging in and out of users
Table of Contents
- addResetCode() : string
- Adds a code for the user to reset its password
- addTooManyLoginsEmailByUserId() : mixed
- Adds a too many login try of a user in the databse
- checkPassword() : bool
- countLoginTriesByTimeSpan() : int
- Counts the login tries after a given time
- createLoginToken() : Session
- Creates a login token for a user
- disableResetCode() : mixed
- Disabled a password reset code
- getResetCode() : mixed
- Gets the dataset of a reset code
- getUserByLogin() : bool|array<string|int, mixed>|null
- Gets an user by its email
- newLoginTry() : mixed
- Rescords a new login try of a user
- sendTooManyLoginsEmailByUserId() : bool
- sendTooManyLoginsEmailByUserId
- updatePassword() : void
- Updates the password of an user
Methods
addResetCode()
Adds a code for the user to reset its password
public
addResetCode(int $userId, string $ref, string $reason) : string
Parameters
- $userId : int
-
The id of the user
- $ref : string
-
The reference
- $reason : string
-
The reason of the reset
Return values
string —The reference
addTooManyLoginsEmailByUserId()
Adds a too many login try of a user in the databse
public
addTooManyLoginsEmailByUserId(int $userId) : mixed
Parameters
- $userId : int
-
Id of the user
Return values
mixed —checkPassword()
public
checkPassword(string $password, string $hash, string $salt) : bool
Parameters
- $password : string
- $hash : string
- $salt : string
Return values
bool —countLoginTriesByTimeSpan()
Counts the login tries after a given time
public
countLoginTriesByTimeSpan(int $userId, string $datetime) : int
Parameters
- $userId : int
-
Id of the user
- $datetime : string
-
The datetime in SQL compatible format
Return values
int —The number of login tries in this time
createLoginToken()
Creates a login token for a user
public
createLoginToken(int $userId, int $exec_userId) : Session
Parameters
- $userId : int
-
Id of the user
- $exec_userId : int
-
Id of the executing user
Return values
Session —The resulting session
disableResetCode()
Disabled a password reset code
public
disableResetCode(int $id) : mixed
Parameters
- $id : int
-
Id of the reset code in the database
Return values
mixed —getResetCode()
Gets the dataset of a reset code
public
getResetCode(string $code, string $timespan) : mixed
Parameters
- $code : string
-
The reset code
- $timespan : string
-
A sql conform formatted time
Return values
mixed —getUserByLogin()
Gets an user by its email
public
getUserByLogin(string $email) : bool|array<string|int, mixed>|null
Parameters
- $email : string
-
The email of the user to get
Return values
bool|array<string|int, mixed>|null —The dataset of the user
newLoginTry()
Rescords a new login try of a user
public
newLoginTry(int $userId) : mixed
Counting to detect security issues
Parameters
- $userId : int
-
Id of the user
Return values
mixed —sendTooManyLoginsEmailByUserId()
sendTooManyLoginsEmailByUserId
public
sendTooManyLoginsEmailByUserId(int $userId) : bool
Parameters
- $userId : int
-
Id of the user
Return values
bool —RES
updatePassword()
Updates the password of an user
public
updatePassword(User $user, string $password) : void
Parameters
- $user : User
-
The object of the user
- $password : string
-
The raw user password