38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
<?php
|
|
require_once "../../../bootstrap.php";
|
|
require_once "Admin.php";
|
|
|
|
use Backend\Models\AdminUser;
|
|
|
|
//Start the php session
|
|
session_start();
|
|
|
|
if(isset($_POST['aLogin'])){
|
|
|
|
$userName = $_POST["userName"];
|
|
$password = $_POST["password"];
|
|
|
|
$user = AdminUser::firstWhere('user_name', $userName );
|
|
if($user){
|
|
$hashedPassword = $user->password;
|
|
if(password_verify($password, $hashedPassword )){
|
|
$_SESSION['userName'] = $userName;
|
|
$_SESSION['admin'] = true;
|
|
$_SESSION['success'] = "You are now logged in";
|
|
header('location: ../../../Frontend/index.html?login=success');
|
|
}else{
|
|
session_destroy();
|
|
header('location: ../../../Frontend/index.html?login=failed?reason=password');
|
|
exit();
|
|
}
|
|
|
|
}else{
|
|
session_destroy();
|
|
header('location: ../../../Frontend/index.html?login=failed?reason=username');
|
|
exit();
|
|
}
|
|
|
|
}else{
|
|
header("location: ../../../Frontend/index.html?error=NoLogin");
|
|
exit();
|
|
} |