Introduction
Authentication controller for user management and login functionality
Overview
The Authentication
class extends MY_Controller
and provides functionality for user authentication, login, password reset, and user settings management.
Methods
getUser
Retrieves the currently logged-in user’s data.
User data object if a user is logged in, null otherwise.
showLogin
Displays the login page.
checkLogin
Checks if a user is currently logged in.
JSON object containing login status and menu text.
loginUser
Processes user login attempt.
This method handles form submission from the login page and redirects the user based on authentication results.
resetPw
Initiates the password reset process for a given email address.
This method sends a password reset email to the user if the email address is valid and associated with an account.
logout
Logs out the current user and destroys the session.
usersettings
Displays the user settings page.
updateUser
Updates user information based on form submission.
This method handles form validation and updates user data, including password if provided.
Helper Methods
password_check
Validates password strength.
True if the password meets the required criteria, false otherwise.
email_exists
Checks if an email address exists in the newsletter subscribers list.
True if the email exists, false otherwise.
Dependencies
- This class relies on the
Authentication_model
for database operations. - PHPMailer is used for sending password reset emails.
- A custom
PasswordHash
library is used for password hashing.
Make sure to configure the email settings properly for the password reset functionality to work correctly.