\Vigas\Application\ModelUserManager

Class UserManager.

Manages an authenticated user account

Summary

Methods
Properties
Constants
__construct()
createAccount()
logUser()
changePassword()
testTokenValidity()
resetPassword()
sendResetPwdEmail()
findEmail()
getPlatformAccountsFromDB()
setFirstLinkDone()
logOut()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$user
$db
N/A

Properties

$db

$db : \PDO

Type

\PDO — Database connection object

Methods

__construct()

__construct() 

Sets user and db attributes

createAccount()

createAccount(string  $username, string  $email, string  $password, string  $password2, string|null  $remember_me = null) : string

Validates given data to create a user account and calls insertUser method

Parameters

string $username

The user username

string $email

The user email address

string $password

The user password

string $password2

The user password (confirm your password field)

string|null $remember_me

The remember me checkbox

Returns

string —

The error message if some data were not validated

logUser()

logUser(string  $username, string  $password, string|null  $remember_me = null) : string

Logs a user, gets his streaming platform accounts and redirect him to the following page

Parameters

string $username

The user username

string $password

The user password

string|null $remember_me

The remember me checkbox

Returns

string —

The error message if the user or password are wrong

changePassword()

changePassword(string  $current_password, string  $new_password, string  $new_password_2) : string

Validates given data to change a user paswword and calls updatePassword method

Parameters

string $current_password

The user current password

string $new_password

The new user password

string $new_password_2

The new user password (confirm your password field)

Returns

string —

The error message if some data were not validated

testTokenValidity()

testTokenValidity(integer  $id, string  $token) : boolean

Tests if the reset password token is still valid (not expired)

Parameters

integer $id

The user id

string $token

The reset password token

Returns

boolean —

Returns true if the token is valid, false otherwise

resetPassword()

resetPassword(integer  $id, string  $token, string  $new_password, string  $new_password_2) : string

Validates given data to reset a user paswword and calls updatePassword method

Parameters

integer $id

The user id

string $token

The reset password token

string $new_password

The new user password

string $new_password_2

The new user password (confirm your password field)

Returns

string —

The error message if some data were not validated

sendResetPwdEmail()

sendResetPwdEmail(string  $email) : string

Sends an email with a reset password link

Parameters

string $email

The user email address

Returns

string —

Confirmation message that the email has been sent or an error message

findEmail()

findEmail(string  $username) : string

Finds a user email address with a given username

Parameters

string $username

The user username

Returns

string —

The user email address or a message saying that the username has not been found

getPlatformAccountsFromDB()

getPlatformAccountsFromDB() 

Gets the user's streaming platform accounts from the database

setFirstLinkDone()

setFirstLinkDone() : string

Calls the firstLinkDone method and redirect the user to the following page

Returns

string —

An error message if the firstLinkDone method returned false

logOut()

logOut() 

Destroys user cookie and session and redirect the user to the main page