finition authentification
This commit is contained in:
parent
5df73b3ac0
commit
0c349e7aed
2 changed files with 34 additions and 19 deletions
|
|
@ -10,7 +10,6 @@ function login_ctrl() {
|
|||
login_form_ctrl($ask_route);
|
||||
}
|
||||
}
|
||||
|
||||
function verify_login_ctrl(?string $route) {
|
||||
require('models/connection.php');
|
||||
require('models/user_crud.php');
|
||||
|
|
@ -23,32 +22,30 @@ function verify_login_ctrl(?string $route) {
|
|||
$_SESSION['login'] = $user['login'];
|
||||
$_SESSION['role'] = $user['type'];
|
||||
if ($route) {
|
||||
header('Location: index.php?route=' . $route);
|
||||
} else {
|
||||
switch ($user['type']) {
|
||||
case 'admin':
|
||||
header('Location: index.php?route=admin');
|
||||
break;
|
||||
case 'lecteur':
|
||||
header('Location: index.php?route=operations');
|
||||
break;
|
||||
default:
|
||||
header('Location: index.php');
|
||||
break;
|
||||
}
|
||||
}
|
||||
header('Location: index.php?route=' . $route);
|
||||
} else {
|
||||
switch ($user['type']) {
|
||||
case 'admin':
|
||||
header('Location: index.php?route=admin');
|
||||
break;
|
||||
case 'administration':
|
||||
header('Location: index.php?route=operations');
|
||||
break;
|
||||
default:
|
||||
header('Location: index.php');
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
echo 'Erreur d\'authentification.';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function login_form_ctrl(?string $route) {
|
||||
require('views/login_views.php');
|
||||
login_form_view($route);
|
||||
}
|
||||
|
||||
function logout_ctrl() {
|
||||
session_unset();
|
||||
session_destroy();
|
||||
|
|
|
|||
|
|
@ -18,11 +18,29 @@ function verify_login_ctrl(?string $route) {
|
|||
$passwd = isset($_POST['password']) ? $_POST['password'] : '';
|
||||
$c = connection();
|
||||
$user = recuperation_auth($c, $login);
|
||||
|
||||
var_dump($user);
|
||||
var_dump(password_verify($passwd, $user['passwd'] ?? ''));
|
||||
exit;
|
||||
if ($user && password_verify($passwd, $user['passwd'])) {
|
||||
session_regenerate_id(true);
|
||||
$_SESSION['login'] = $user['login'];
|
||||
$_SESSION['role'] = $user['type'];
|
||||
header('Location: index.php?route=' . $route);
|
||||
if ($route) {
|
||||
header('Location: index.php?route=' . $route);
|
||||
} else {
|
||||
switch ($user['type']) {
|
||||
case 'admin':
|
||||
header('Location: index.php?route=admin');
|
||||
break;
|
||||
case 'lecteur':
|
||||
header('Location: index.php?route=operations');
|
||||
break;
|
||||
default:
|
||||
header('Location: index.php');
|
||||
break;
|
||||
}
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
echo 'Erreur d\'authentification.';
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue