2015-06-29 22:51:29 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-06-30 20:57:20 +00:00
|
|
|
angular.module('users').controller('PasswordController', ['$scope', '$stateParams', '$state', 'User',
|
|
|
|
function($scope, $stateParams, $state, User) {
|
2015-08-25 21:33:52 +00:00
|
|
|
|
2016-08-26 05:48:44 +00:00
|
|
|
$scope.error = '';
|
|
|
|
|
2015-07-28 22:29:07 +00:00
|
|
|
// Submit forgotten password account id
|
|
|
|
$scope.askForPasswordReset = function() {
|
|
|
|
User.askForPasswordReset($scope.credentials).then(
|
|
|
|
function(response){
|
|
|
|
$scope.success = response.message;
|
|
|
|
$scope.credentials = null;
|
|
|
|
},
|
|
|
|
function(error){
|
|
|
|
$scope.error = error;
|
|
|
|
$scope.credentials = null;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2015-06-30 16:30:56 +00:00
|
|
|
|
2015-07-28 22:29:07 +00:00
|
|
|
// Change user password
|
|
|
|
$scope.resetUserPassword = function() {
|
|
|
|
$scope.success = $scope.error = null;
|
|
|
|
User.resetPassword($scope.passwordDetails, $stateParams.token).then(
|
|
|
|
function(response){
|
|
|
|
// If successful show success message and clear form
|
|
|
|
$scope.success = response.message;
|
|
|
|
$scope.passwordDetails = null;
|
2015-06-30 17:36:51 +00:00
|
|
|
|
2015-07-28 22:29:07 +00:00
|
|
|
// And redirect to the index page
|
|
|
|
$state.go('reset-success');
|
|
|
|
},
|
|
|
|
function(error){
|
|
|
|
$scope.error = error.message || error;
|
|
|
|
$scope.passwordDetails = null;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
};
|
2015-06-29 22:51:29 +00:00
|
|
|
}
|
2016-08-26 05:48:44 +00:00
|
|
|
]);
|