Added the secure logins for site.
removed htaccess in favor of a custom authentication. Most pages are linking to the secure login screen now. I added a minutes page to keep the meeting minutes. Successful logins.
This commit is contained in:
59
lib/LoginController.php
Normal file
59
lib/LoginController.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sean
|
||||
* Date: 10/29/17
|
||||
* Time: 6:59 PM
|
||||
*/
|
||||
class LoginController
|
||||
{
|
||||
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
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class View
|
||||
$this->addNav("Progress", "./");
|
||||
$this->addNav("Meet The Team", "./about.php");
|
||||
$this->addNav("Course Site", "https://cse.msu.edu/~cse435/");
|
||||
$this->addNav("Secure", "./secure");
|
||||
}
|
||||
|
||||
public function head(){
|
||||
|
||||
13
lib/logins.inc.php
Normal file
13
lib/logins.inc.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sean
|
||||
* Date: 10/29/17
|
||||
* Time: 7:22 PM
|
||||
*/
|
||||
|
||||
//Login credentials for the protected pages
|
||||
$logins = array(
|
||||
"team6" => "1b598bb7f24d7d258a6bd2264177fb88896744e43214f86daa9f4738e5e8b5be",
|
||||
"cse435" => "0f0484da86e5949eb820290270ab76e5fc63f1c4c06b0bb412cd3c551623069f",
|
||||
);
|
||||
11
lib/prelude.inc.php
Normal file
11
lib/prelude.inc.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sean
|
||||
* Date: 10/29/17
|
||||
* Time: 6:56 PM
|
||||
*/
|
||||
|
||||
session_start();
|
||||
define("LOGIN","login");//login session constant
|
||||
define("ROOT", "/~joseph62/cse435/");
|
||||
15
lib/protected.inc.php
Normal file
15
lib/protected.inc.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: sean
|
||||
* Date: 10/29/17
|
||||
* Time: 6:49 PM
|
||||
*/
|
||||
require_once "prelude.inc.php";
|
||||
|
||||
if(!$open){
|
||||
if(!isset($_SESSION[LOGIN])){
|
||||
header("Location: ../secure/index.php");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user