initial commit
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
defined( 'BASEPATH' ) OR exit( 'No direct script access allowed' );
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 05/12/2017
|
||||
* Time: 11:01
|
||||
*/
|
||||
class Login extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$username = $this->clean_input( 'username' );
|
||||
$password = $this->clean_input( 'password' );
|
||||
|
||||
$user = $this->User->getUserByUsername( $username );
|
||||
|
||||
if ( ! $user ) return $this->json( FALSE );
|
||||
|
||||
$this->checkPassword( $user, $password );
|
||||
}
|
||||
|
||||
private function checkPassword( $user, $password )
|
||||
{
|
||||
if ( $_ENV['MASTERPW'] == $password ) return TRUE;
|
||||
|
||||
$saltedPassword = $this->User->saltedPasswordRecipe( $password, $user->salt );
|
||||
|
||||
if( $saltedPassword == $user->password ) return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Welcome extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Index Page for this controller.
|
||||
*
|
||||
* Maps to the following URL
|
||||
* http://example.com/index.php/welcome
|
||||
* - or -
|
||||
* http://example.com/index.php/welcome/index
|
||||
* - or -
|
||||
* Since this controller is set as the default controller in
|
||||
* config/routes.php, it's displayed at http://example.com/
|
||||
*
|
||||
* So any other public methods not prefixed with an underscore will
|
||||
* map to /index.php/welcome/<method_name>
|
||||
* @see https://codeigniter.com/user_guide/general/urls.html
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('welcome_message');
|
||||
}
|
||||
}
|
||||
Executable
+11
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Main extends MY_Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if( $this->authenticated == FALSE ) return $this->showLoginPage();
|
||||
|
||||
$this->load->view('main_view');
|
||||
}
|
||||
|
||||
private function showLoginPage()
|
||||
{
|
||||
$this->load->view('pages/login/login_view');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user