Request class and begin Frontend.
This commit is contained in:
49
src/Helpers/Authentification.php
Normal file
49
src/Helpers/Authentification.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
class Authentification {
|
||||
|
||||
/**
|
||||
* Permet de démarrer la variable Session.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function startSession(): void {
|
||||
session_start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de supprimer la session.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function destroySession(): void {
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de connecter un utilisateur.
|
||||
*
|
||||
* @param int $userId
|
||||
* @return void
|
||||
*/
|
||||
public static function loginUser( int $userId ){
|
||||
$_SESSION['user'] = $userId;
|
||||
}
|
||||
|
||||
// TODO : Complete when user.
|
||||
public static function getCurrentUser() {
|
||||
return $_SESSION['user'] ?? false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet de savoir si un utilisateur est connecté ou pas.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isLoggedIn(): bool {
|
||||
return self::getCurrentUser() !== false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user