Documentation

AuthController
in package

Authentication Controller

Handles user authentication, registration, session management and user data retrieval. This controller acts as a bridge between the user interface (the views) and the UserManager model, managing the authentication workflow and session state.

Tags
author

Mohamed-Amine Boudhib, Thomas Palot, Amin Helali, Willem Chetioui

version
1.0.0

Table of Contents

Properties

$userManager  : UserManager
User manager instance for database operations

Methods

__construct()  : mixed
Constructor - Initialize the AuthController
getCurrentUserFullName()  : string|null
Get the current logged-in user's full name
login()  : bool
Authenticate a user with email and password
logout()  : void
Handle user logout
register()  : int|false
Register a new user

Properties

Methods

__construct()

Constructor - Initialize the AuthController

public __construct() : mixed

Creates a new UserManager instance for handling user-related database operations.

getCurrentUserFullName()

Get the current logged-in user's full name

public getCurrentUserFullName() : string|null

Returns the user's first name and last name concatenated.

Return values
string|null

The user's full name, or null if not logged in

login()

Authenticate a user with email and password

public login(string $email, string $pwd) : bool

Validates user credentials against the database. If successful, creates a new session and stores user information in session variables.

Parameters
$email : string

The user's email address

$pwd : string

The user's password

Return values
bool

True if authentication successful, false otherwise

logout()

Handle user logout

public logout() : void

Destroys the current session and redirects to home page. Clears all session data and cookies associated with the user's session.

register()

Register a new user

public register(string $last_name, string $first_name, string $user_status, string $email, string $pwd) : int|false

Creates a new user account after validating the email format and checking for duplicate email addresses. The password is hashed before storage.

Parameters
$last_name : string

User's last name

$first_name : string

User's first name

$user_status : string

User's class year (1, 2, or 3)

$email : string

User's email address

$pwd : string

User's password (will be hashed)

Return values
int|false

The new user ID if successful, false otherwise


        
On this page

Search results