diff --git a/.gitignore b/.gitignore index 93c4797..023c02f 100755 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,5 @@ user_guide_src/cilexer/pycilexer.egg-info/* /tests/tests/ /tests/results/ /resources +/.env +/themeforest diff --git a/application/config/autoload.php b/application/config/autoload.php index 7cdc901..34afbb7 100755 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -1,5 +1,5 @@ 'ua'); */ -$autoload['libraries'] = array(); +$autoload['libraries'] = array('database', 'session'); /* | ------------------------------------------------------------------- @@ -132,4 +132,4 @@ $autoload['language'] = array(); | | $autoload['model'] = array('first_model' => 'first'); */ -$autoload['model'] = array(); +$autoload['model'] = ['beheer/User']; diff --git a/application/config/config.php b/application/config/config.php index 1031522..2cc405e 100755 --- a/application/config/config.php +++ b/application/config/config.php @@ -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; diff --git a/application/config/database.php b/application/config/database.php index bf9857f..1b40188 100755 --- a/application/config/database.php +++ b/application/config/database.php @@ -75,10 +75,10 @@ $query_builder = TRUE; $db['default'] = array( 'dsn' => '', - 'hostname' => 'localhost', - 'username' => '', - 'password' => '', - 'database' => '', + 'hostname' => getenv('DB_HOST'), + 'username' => getenv('DB_USER'), + 'password' => getenv('DB_PASS'), + 'database' => getenv('DB_NAME'), 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, diff --git a/application/controllers/Login.php b/application/controllers/Login.php index 145122f..f282263 100644 --- a/application/controllers/Login.php +++ b/application/controllers/Login.php @@ -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->createusersession->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; } diff --git a/application/controllers/main.php b/application/controllers/Main.php similarity index 83% rename from application/controllers/main.php rename to application/controllers/Main.php index 10d5336..8767f55 100755 --- a/application/controllers/main.php +++ b/application/controllers/Main.php @@ -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'); } diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php index 4af4152..31e6b32 100644 --- a/application/core/MY_Controller.php +++ b/application/core/MY_Controller.php @@ -14,17 +14,23 @@ 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 ) { - return str_replace( 'null', '', $this->db->escape_str( $this->input->post( $post ), TRUE ) ); + $value = $this->input->input_stream( $post, TRUE ); + + $denulledValue = str_replace( 'null', '', $value); + + return $denulledValue; } public function json($data) diff --git a/application/libraries/beheer/CreateUserSession.php b/application/libraries/beheer/CreateUserSession.php new file mode 100644 index 0000000..9766b7f --- /dev/null +++ b/application/libraries/beheer/CreateUserSession.php @@ -0,0 +1,47 @@ +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 ); + } + +} \ No newline at end of file diff --git a/application/libraries/beheer/RetrieveUserSession.php b/application/libraries/beheer/RetrieveUserSession.php new file mode 100644 index 0000000..3750d01 --- /dev/null +++ b/application/libraries/beheer/RetrieveUserSession.php @@ -0,0 +1,41 @@ +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 ); + } +} \ No newline at end of file diff --git a/application/models/beheer/User.php b/application/models/beheer/User.php new file mode 100644 index 0000000..bf38e31 --- /dev/null +++ b/application/models/beheer/User.php @@ -0,0 +1,26 @@ +get( [ + 'UCASE(username)' => strtoupper( $username )], FALSE, TRUE); + + return $user; + } + +} \ No newline at end of file diff --git a/application/views/main_view.php b/application/views/main_view.php new file mode 100644 index 0000000..4963fc7 --- /dev/null +++ b/application/views/main_view.php @@ -0,0 +1,52 @@ + + + + + + + + + + + +** De Beleidsonderzoeker ** + +load->view('partials/_css'); ?> + +load->view('partials/_fonts'); ?> + + + + + + + + \ No newline at end of file diff --git a/application/views/pages/login/login_view.php b/application/views/pages/login/login_view.php index 5304a8d..9f102d6 100644 --- a/application/views/pages/login/login_view.php +++ b/application/views/pages/login/login_view.php @@ -35,25 +35,28 @@ load->view('specials/notify_modal'); ?> +load->view('specials/notifyme_modal'); ?>
-
+
...

projectbeheer

-
+
- +
- +
- +
@@ -103,6 +106,7 @@ + diff --git a/application/views/partials/_css.php b/application/views/partials/_css.php new file mode 100644 index 0000000..06a1766 --- /dev/null +++ b/application/views/partials/_css.php @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/application/views/partials/_fonts.php b/application/views/partials/_fonts.php new file mode 100644 index 0000000..e5d0d27 --- /dev/null +++ b/application/views/partials/_fonts.php @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/application/views/partials/_navbar-container/_navbar-right.php b/application/views/partials/_navbar-container/_navbar-right.php new file mode 100644 index 0000000..b72251f --- /dev/null +++ b/application/views/partials/_navbar-container/_navbar-right.php @@ -0,0 +1,221 @@ + \ No newline at end of file diff --git a/application/views/partials/_navbar-container/_navbar-toolbar.php b/application/views/partials/_navbar-container/_navbar-toolbar.php new file mode 100644 index 0000000..de7f7ab --- /dev/null +++ b/application/views/partials/_navbar-container/_navbar-toolbar.php @@ -0,0 +1,188 @@ + \ No newline at end of file diff --git a/application/views/partials/_navbar-header.php b/application/views/partials/_navbar-header.php new file mode 100644 index 0000000..6bb2097 --- /dev/null +++ b/application/views/partials/_navbar-header.php @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/application/views/specials/notifyme_modal.php b/application/views/specials/notifyme_modal.php new file mode 100644 index 0000000..bf642dc --- /dev/null +++ b/application/views/specials/notifyme_modal.php @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/composer.json b/composer.json index 30630e2..ac9671c 100755 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "source": "https://github.com/bcit-ci/CodeIgniter" }, "require": { - "php": ">=5.3.7" + "php": ">=5.3.7", + "vlucas/phpdotenv": "^2.4" }, "suggest": { "paragonie/random_compat": "Provides better randomness in PHP 5.x" diff --git a/public/index.php b/public/index.php index 82920d1..6c67e0f 100755 --- a/public/index.php +++ b/public/index.php @@ -1,4 +1,19 @@ load(); + +$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'ENVIRONMENT']); + + /** * CodeIgniter * @@ -53,7 +68,7 @@ * * NOTE: If you change these, also change the error_reporting() code below */ - define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); + define('ENVIRONMENT', getenv('ENVIRONMENT')); /* *--------------------------------------------------------------- diff --git a/public/js/lib/modules/login/loginModule.js b/public/js/lib/modules/login/loginModule.js index 23cfa0c..0af2c8d 100644 --- a/public/js/lib/modules/login/loginModule.js +++ b/public/js/lib/modules/login/loginModule.js @@ -5,6 +5,7 @@ * Time: 11:17 */ var dbo = {}; + $( function () { dbo.loginModel = { @@ -16,9 +17,8 @@ $( function () { dbo.loginService.login(); } } - +console.log( 'text' ); ko.applyBindings( dbo.loginModel, document.getElementById( "login-form" ) ); - } ); dbo.loginService = { @@ -28,11 +28,13 @@ dbo.loginService = { var self = dbo.loginService; var vm = dbo.loginModel; - self.validateInput( function ( data ) { - if ( !data ) return self.notifyWrongPassword(); + self.validateInput( function ( submitDATA ) { + if ( ! submitDATA ) return self.notifyWrongPassword(); ds.login( submitDATA, function ( data ) { if ( data ) return location.reload(); + + self.notifyWrongPassword(); } ); } ); @@ -55,8 +57,7 @@ dbo.loginService = { notifyWrongPassword: function () { notifyMe( { title : 'Login fout', - message: 'Gebruikersnaam / wachtwoord komen niet overeen', - alert : true + message: 'Gebruikersnaam / wachtwoord komen niet overeen' } ); } }; diff --git a/public/js/lib/modules/specials/notifyModule.js b/public/js/lib/modules/specials/notifyModule.js index 7974324..dfa7d19 100644 --- a/public/js/lib/modules/specials/notifyModule.js +++ b/public/js/lib/modules/specials/notifyModule.js @@ -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; @@ -36,11 +37,10 @@ dbo.notifyModel = { vm.title( options.title || '' ); vm.message( options.message || '' ); vm.notify( options.notify || false ); - vm.alert( options.alert || false ); vm.noText( options.noText || 'Nee' ); vm.yesText( options.yesText || 'Ja' ); vm.closeText( options.closeText || 'ok' ); - vm.modalClass( options.modalClass || 'modal-primary'); + vm.modalClass( options.modalClass || 'modal-primary' ) }, closeNo: function () {