Skip to content

Commit

Permalink
Merge pull request pencilblue#1126 from pencilblue/issue1109
Browse files Browse the repository at this point in the history
fixes pencilblue#1109 - reset password in angular
  • Loading branch information
brianhyder authored Aug 17, 2016
2 parents a7692f4 + 133154b commit 1e97d4d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions plugins/pencilblue/controllers/user/change_password.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ module.exports = function (pb) {
return self.redirect('/', cb);
}


var uiEntities = ClientJs.getAngularObjects(ChangePasswordFormController.gatherNavData(self.ls));
var uiEntities = ChangePasswordFormController.gatherNavData(self.ls);
uiEntities.resetPassword = self.session.authentication.reset_password || false;
var angularObjects = ClientJs.getAngularObjects(uiEntities);
self.setPageName(self.ls.g('users.CHANGE_PASSWORD'));
self.ts.registerLocal('angular_objects', new pb.TemplateValue(uiEntities, false));
self.ts.registerLocal('angular_objects', new pb.TemplateValue(angularObjects, false));
self.ts.load('user/change_password', function(err, result) {

cb({content: result});
Expand Down
13 changes: 8 additions & 5 deletions plugins/pencilblue/templates/angular/user/change_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
<script type="text/javascript" src="/js/angular/services/password.js"></script>
<script type="text/javascript">
angular.module('pencilblueApp', ['validation', 'password'])
.controller('PencilBlueController', function($scope, $http, validationService, passwordService) {
.controller('PencilBlueController', function($scope, $http, $window, validationService, passwordService) {
^angular_objects^
^tmp_angular=admin=elements=is_field_valid^

$scope.userPassword = {};

$scope.checkPasswordMatch = function() {
$scope.passwordMatch = passwordService.checkPasswordMatch($scope.userPassword.new_password, $scope.userPassword.confirm_password);
}
};

$scope.generatePassword = function() {
$scope.passwordGenerated = true;
$scope.userPassword.new_password = passwordService.generatePassword();
$scope.userPassword.confirm_password = $scope.userPassword.new_password.toString();
$scope.checkPasswordMatch();
}
};

$scope.resetPasswordGenerated = function() {
$scope.passwordGenerated = false;
}
};

$scope.getPasswordInputType = function() {
return $scope.passwordGenerated ? 'text' : 'password';
}
};

$scope.savePassword = function() {
$scope.formSubmitted = true;
Expand All @@ -42,6 +42,9 @@
$scope.saving = false;
$scope.formSubmitted = false;
$scope.userPassword = {};
if ($scope.resetPassword) {
$window.location = '/actions/logout';
}
})
.error(function(error, status) {
$scope.errorMessage = error.message;
Expand Down
2 changes: 1 addition & 1 deletion plugins/pencilblue/templates/user/change_password.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<fieldset>
<div class="tab-content">
<div class="tab-pane active" id="password">
<div class="form-group" ng-class="{'has-error': !isFieldValid(changePasswordForm.current_password)}">
<div class="form-group" ng-class="{'has-error': !isFieldValid(changePasswordForm.current_password)}" ng-if="!resetPassword">
<label>^loc_CURRENT_PASSWORD^</label>
<input type="password" name="current_password" class="form-control" ng-model="userPassword.current_password" required></input>
<div class="form_error" ng-if="!isFieldValid(changePasswordForm.current_password)">^loc_REQUIRED_FIELD^</div>
Expand Down

0 comments on commit 1e97d4d

Please sign in to comment.