change password

This commit is contained in:
2019-05-07 21:41:49 +02:00
parent 2738f8aa78
commit b3e8eecca6
5 changed files with 105 additions and 12 deletions
@@ -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] );
+22
View File
@@ -30,9 +30,31 @@
</div>
</div>
</div>
<div class="col-xs-9 col-xs-offset-3">
<a href="#" class="dbois-exit"
data-bind="click:logOut">uitloggen</a>
<div class="clock"></div>
<!-- ko if: hidePasswordinput() -->
<label class="change-password"
data-bind="click:togglePasswordinput">
wachtwoord wijzigen
</label>
<!-- /ko -->
<!-- ko if: ! hidePasswordinput() -->
<div class="change-password">
<div class="col-xs-5">
<input type="password"
data-bind="textinput:newPassword, event:{'keyup':checkPassword}"
class="form-control" placeholder="type hier uw wachtwoord" />
</div>
<div class="col-xs-2">
<button class="btn btn-success"
data-bind="disable:!validPassword(),click:savePassword">wachtwoord aanvragen</button>
</div>
</div>
<!-- /ko -->
</div>
</div>
<div class="wrapper">
<?php $this->load->view( 'partials/_navbar-left' ); ?>
+13
View File
@@ -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;
}
@@ -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 () {
+40
View File
@@ -12,6 +12,9 @@ $( function () {
pages : ko.observable(),
initialized : ko.observable( false ),
hidePasswordinput: ko.observable(true),
newPassword : ko.observable(),
validPassword : ko.observable(),
init: function () {
@@ -32,6 +35,16 @@ $( function () {
} );
},
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();
@@ -39,6 +52,33 @@ $( function () {
},
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 ) {
var vm = dbo.menuModel;