AuthService
class AuthService
Supports authentication operations.
Methods
Checks if a user is logged in.
Hashes a plain text password using PHP's password_hash() with the default algorithm.
Tests for login attempts and sets session messages when there is a failed attempt or when account is locked.
Creates a session when the user logs in. A new record is added to the user_sessions table and a cookie is created if remember me is selected.
Logs in user from cookie.
Logs out the currently logged-in user by clearing the session and deleting any active cookies.
Perform logout operation on current logged in user. The record for the current logged in user is removed from the user_session table and the corresponding cookie is deleted.
Handles the complete flow of resetting a user’s password, including setting the confirmation field and updating the record.
Processes a profile image upload and returns an Uploads object.
Details
at line 27
static string
confirm(Input $request)
Gets value of password confirm field. Assumes field value is "confirm".
at line 37
static Users|false|null
currentUser()
Checks if a user is logged in.
at line 51
static string
hashPassword(string $password)
Hashes a plain text password using PHP's password_hash() with the default algorithm.
at line 67
static Login
login(Input $request, Login $loginModel, string $username, bool $mailer = false)
Attempts to log a user in. If successful, resets login attempts and creates a session. Otherwise, tracks failed attempts and optionally triggers an email notification.
at line 107
static Login
loginAttempts(Users $user, Login $loginModel, bool $mailer = false)
Tests for login attempts and sets session messages when there is a failed attempt or when account is locked.
at line 136
static void
loginUser(Users $loginUser, bool $rememberMe = false)
Creates a session when the user logs in. A new record is added to the user_sessions table and a cookie is created if remember me is selected.
at line 171
static Users|null
loginUserFromCookie()
Logs in user from cookie.
at line 189
static void
logout()
Logs out the currently logged-in user by clearing the session and deleting any active cookies.
at line 204
static bool
logoutUser(Users $user)
Perform logout operation on current logged in user. The record for the current logged in user is removed from the user_session table and the corresponding cookie is deleted.
at line 226
static void
passwordReset(Input $request, Users $user)
Handles the complete flow of resetting a user’s password, including setting the confirmation field and updating the record.
at line 250
static Uploads|null
profileImageUpload(Users $user)
Processes a profile image upload and returns an Uploads object.
Assumes the input name is profileImage.