diff --git a/application/controllers/beheer/UsersController.php b/application/controllers/beheer/UsersController.php index 420f822..eee3f02 100644 --- a/application/controllers/beheer/UsersController.php +++ b/application/controllers/beheer/UsersController.php @@ -82,6 +82,17 @@ class usersController extends MY_Controller { $this->json( ['success' => TRUE, 'userID' => $userID] ); } + public function savePassword() + { + $password = $this->clean_input( 'password' ); + + $user = User::find( USERID ); + + $saltedPassword = User::getSaltedPassword( $password, $user->salt ); + + User::whereId( USERID )->update( ['password' => $saltedPassword] ); + } + public function archiveUser( $userID, $status ) { User::whereId( $userID )->update( ['archive' => $status] ); diff --git a/application/views/main_view.php b/application/views/main_view.php index 798e2be..7effca0 100644 --- a/application/views/main_view.php +++ b/application/views/main_view.php @@ -30,9 +30,31 @@ - uitloggen -
+
+ uitloggen +
+ + + + +
+
+ +
+
+ +
+
+ + +
load->view( 'partials/_navbar-left' ); ?> diff --git a/public/css/menu.css b/public/css/menu.css index 53dd988..3fb9601 100644 --- a/public/css/menu.css +++ b/public/css/menu.css @@ -269,4 +269,17 @@ top: -2px; margin-right:10px } +label.change-password { + float: right; + margin-top: 8px;; +} +label.change-password:hover { + color: #fff; + cursor: pointer; +} +div.change-password { + margin-right: 140px; + float: right; +} + diff --git a/public/js/lib/dataservices/userDataservice.js b/public/js/lib/dataservices/userDataservice.js index 339b51f..d2de73c 100644 --- a/public/js/lib/dataservices/userDataservice.js +++ b/public/js/lib/dataservices/userDataservice.js @@ -58,6 +58,13 @@ dbo.userDataService = { } ); }, + savePassword: function ( password, callback ) { + $.post( '/index.php/beheer/usersController/savePassword', {password: password} ) + .done( function () { + callback(); + } ); + }, + archiveUser: function ( userID, status, callback ) { $.get( 'index.php/beheer/usersController/archiveUser/' + userID + '/' + status ) .done( function () { diff --git a/public/js/lib/modules/menuModule.js b/public/js/lib/modules/menuModule.js index f573075..7d8e0ce 100644 --- a/public/js/lib/modules/menuModule.js +++ b/public/js/lib/modules/menuModule.js @@ -10,8 +10,11 @@ $( function () { dbo.menuModel = { - pages : ko.observable(), - initialized: ko.observable( false ), + pages : ko.observable(), + initialized : ko.observable( false ), + hidePasswordinput: ko.observable(true), + newPassword : ko.observable(), + validPassword : ko.observable(), init: function () { @@ -32,11 +35,48 @@ $( function () { } ); }, - logOut : function(){ - dbo.userDataService.logOut(function(){ - location.reload(); - }); + checkPassword: function () { + var vm = dbo.menuModel; + if ( vm.newPassword().length >= 8 ) { + vm.validPassword( true ); + } else { + vm.validPassword( false ); + } + }, + + logOut: function () { + dbo.userDataService.logOut( function () { + location.reload(); + } ); + + }, + + togglePasswordinput: function () { + if ( dbo.menuModel.hidePasswordinput() == true ) { + var tellMeOptions = { + title : 'Wijzig wachtwoord', + message : 'Uw gewijzigde wachtwoord dient uit tenminste 8 tekens te bestaan', + modalClass: 'modal-warning' + } + tellMe( tellMeOptions ) + } + dbo.menuModel.hidePasswordinput( !dbo.menuModel.hidePasswordinput() ); + }, + + savePassword: function () { + var vm = dbo.menuModel; + + dbo.userDataService.savePassword( vm.newPassword, function () { + var tellMeOptions = { + title : 'Uw wachtwoord is gewijzigd', + message : 'U kunt nu met uw gewijzigde wachtwoord inloggen', + modalClass: 'modal-warning' + } + tellMe( tellMeOptions ); + + dbo.menuModel.hidePasswordinput( !dbo.menuModel.hidePasswordinput() ); + } ) }, setPage: function ( page ) { @@ -59,9 +99,9 @@ $( function () { dbo.menuModel.init(); - $(".open-submenu").click(function(){ - $("#sub-" + $(this).attr('id')).slideToggle('slow'); - }); + $( ".open-submenu" ).click( function () { + $( "#sub-" + $( this ).attr( 'id' ) ).slideToggle( 'slow' ); + } ); } );