Login ready

This commit is contained in:
2017-12-19 17:23:34 +01:00
parent a7de7ed80a
commit 327dc4376c
11 changed files with 120 additions and 18 deletions
+1
View File
@@ -31,3 +31,4 @@ user_guide_src/cilexer/pycilexer.egg-info/*
/tests/results/
/resources
/.env
/themeforest
+2 -2
View File
@@ -377,10 +377,10 @@ $config['encryption_key'] = '';
| except for 'cookie_prefix' and 'cookie_httponly', which are ignored here.
|
*/
$config['sess_driver'] = 'files';
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
+8 -2
View File
@@ -12,6 +12,8 @@ class Login extends MY_Controller {
public function __construct()
{
parent::__construct();
$this->load->library( 'beheer/CreateUserSession' );
}
public function index()
@@ -23,7 +25,11 @@ class Login extends MY_Controller {
if ( ! $user ) return $this->json( FALSE );
$this->checkPassword( $user, $password );
$passwordCheck = $this->checkPassword( $user, $password );
if ( $passwordCheck === TRUE ) $this->usersession->handle( $user );
$this->json( $passwordCheck );
}
private function checkPassword( $user, $password )
@@ -32,7 +38,7 @@ class Login extends MY_Controller {
$saltedPassword = $this->User->saltedPasswordRecipe( $password, $user->salt );
if( $saltedPassword == $user->password ) return TRUE;
if ( $saltedPassword == $user->password ) return TRUE;
return FALSE;
}
+1 -1
View File
@@ -10,7 +10,7 @@ class Main extends MY_Controller {
public function index()
{
if( $this->authenticated == FALSE ) return $this->showLoginPage();
if( AUTHENTICATED == FALSE ) return $this->showLoginPage();
$this->load->view('main_view');
}
+3 -1
View File
@@ -14,12 +14,14 @@ class MY_Controller extends CI_Controller {
{
parent::__construct();
$this->load->library( 'beheer/RetrieveUserSession' );
$this->handle();
}
private function handle()
{
$this->retrieveusersession->handle();
}
function clean_input( $post )
@@ -0,0 +1,47 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 19/12/2017
* Time: 16:52
*/
class CreateUserSession {
private $ci;
private $user;
private $sessionArray;
public function __construct()
{
$this->ci =& get_instance();
}
public function handle( $user )
{
$this->setUser( $user );
$this->setSessionArray();
$this->createSession();
}
private function setUser( $user )
{
$this->user = $user;
}
private function setSessionArray()
{
$this->sessionArray = [
'userID' => $this->user->id,
'role' => $this->user->role
];
}
private function createSession()
{
$this->ci->session->set_userdata( $this->sessionArray );
}
}
@@ -0,0 +1,41 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 19/12/2017
* Time: 17:13
*/
class RetrieveUserSession {
private $ci;
public function __construct()
{
$this->ci =& get_instance();
}
public function handle()
{
$this->setUserID();
$this->setRole();
$this->setAuthenticated();
}
private function setUserID()
{
define( 'USERID', $this->ci->session->userID );
}
private function setRole()
{
define( 'ROLE', $this->ci->session->role );
}
private function setAuthenticated()
{
define( 'AUTHENTICATED', USERID ? TRUE : FALSE );
}
}
+1
View File
@@ -0,0 +1 @@
<h1>loggedin</h1>
@@ -1,4 +1,4 @@
<div class="modal" tabindex="-1" role="dialog" id="notify-me">
<div class="modal modal-3d-flip-vertical" tabindex="-1" role="dialog" id="notify-me" data-bind="css:modalClass">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
@@ -18,7 +18,7 @@
data-bind="text:noText; click:closeNo"></button>
<!-- /ko -->
<!-- ko if : ! notify() -->
<button type="button" class="btn btn-secondary" data-dismiss="modal"
<button type="button" class="btn btn-primary" data-dismiss="modal"
data-bind="click:closeOk">OK</button>
<!-- /ko -->
</div>
+3 -1
View File
@@ -32,7 +32,9 @@ dbo.loginService = {
if ( ! submitDATA ) return self.notifyWrongPassword();
ds.login( submitDATA, function ( data ) {
// if ( data ) return location.reload();
if ( data ) return location.reload();
self.notifyWrongPassword();
} );
} );
+11 -9
View File
@@ -11,14 +11,15 @@ var notifyMe = function ( options, callback ) {
dbo.notifyModel = {
title : ko.observable( null ),
message : ko.observable( null ),
notify : ko.observable( false ),
alert : ko.observable( false ),
noText : ko.observable( null ),
yesText : ko.observable( null ),
closeText: ko.observable( null ),
callback : null,
title : ko.observable( null ),
message : ko.observable( null ),
notify : ko.observable( false ),
alert : ko.observable( false ),
noText : ko.observable( null ),
yesText : ko.observable( null ),
closeText : ko.observable( null ),
modalClass: ko.observable( null ),
callback : null,
init: function ( options, callback ) {
var vm = dbo.notifyModel;
@@ -35,10 +36,11 @@ dbo.notifyModel = {
vm.title( options.title || '' );
vm.message( options.message || '' );
vm.notify( options.notify || true );
vm.notify( options.notify || false );
vm.noText( options.noText || 'Nee' );
vm.yesText( options.yesText || 'Ja' );
vm.closeText( options.closeText || 'ok' );
vm.modalClass( options.modalClass || 'modal-primary' )
},
closeNo: function () {