36 lines
927 B
PHP
36 lines
927 B
PHP
<?php
|
|
require "../../../bootstrap.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['userId'] = $user->id;
|
|
$_SESSION['success'] = "You are now logged in";
|
|
header('location: ../Frontend/index.php?login=success');
|
|
}else{
|
|
session_destroy();
|
|
header('location: ../Frontend/index.php?login=failed?reason=password');
|
|
}
|
|
|
|
|
|
}
|
|
else{
|
|
session_destroy();
|
|
header('location: ../Frontend/index.php?login=failed?reason=username');
|
|
}
|
|
|
|
|
|
} |