Refactored a div class tag to be more general.
Added site style to the secure pages. Renamed LoginController to SecureLoginController.
This commit is contained in:
59
lib/SecureLoginController.php
Normal file
59
lib/SecureLoginController.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sean
|
||||
* Date: 10/29/17
|
||||
* Time: 6:59 PM
|
||||
*/
|
||||
class SecureLoginController
|
||||
{
|
||||
public function __construct($get, $post, $logins)
|
||||
{
|
||||
|
||||
$this->get = $get;
|
||||
$this->post = $post;
|
||||
$this->logins = $logins;
|
||||
|
||||
if(isset($post['username'])){
|
||||
$username = $post['username'];
|
||||
if(array_key_exists($username,$logins)){
|
||||
if(isset($post['password'])) {
|
||||
$hash = hash("sha256", $post['password']);
|
||||
if ($hash == $logins[$username]) {
|
||||
$this->success = true;
|
||||
$this->redirect = "secure/minutes.php";
|
||||
}
|
||||
else{
|
||||
$this->redirect = "secure/index.php";
|
||||
}
|
||||
}
|
||||
else{
|
||||
$this->redirect = "secure/index.php";
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
$this->redirect = "secure/index.php";
|
||||
}
|
||||
}
|
||||
else{
|
||||
$this->redirect = "secure/index.php";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getRedirect(){
|
||||
return $this->redirect;
|
||||
}
|
||||
|
||||
public function validLogin(){
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
private $get; //Get data
|
||||
private $post; //Post data
|
||||
private $logins; //Login data
|
||||
private $success = false; // successful login flag
|
||||
private $redirect; //Redirect location
|
||||
}
|
||||
Reference in New Issue
Block a user