harbor/static/resources/js/layout/reset-password/reset-password.controller.js

53 lines
1.4 KiB
JavaScript
Raw Normal View History

(function() {
'use strict';
angular
.module('harbor.layout.reset.password')
.controller('ResetPasswordController', ResetPasswordController);
ResetPasswordController.$inject = ['$location', 'ResetPasswordService', '$window', 'getParameterByName'];
function ResetPasswordController($location, ResetPasswordService, $window, getParameterByName) {
var vm = this;
vm.resetUuid = getParameterByName('reset_uuid', $location.absUrl());
2016-05-14 07:34:54 +02:00
vm.reset = reset;
vm.resetPassword = resetPassword;
2016-05-14 07:34:54 +02:00
vm.cancel = cancel;
vm.hasError = false;
vm.errorMessage = '';
function reset() {
vm.hasError = false;
vm.errorMessage = '';
}
function resetPassword(user) {
if(user && angular.isDefined(user.password)) {
2016-05-14 07:34:54 +02:00
console.log('rececived password:' + user.password + ', reset_uuid:' + vm.resetUuid);
ResetPasswordService(vm.resetUuid, user.password)
.success(resetPasswordSuccess)
.error(resetPasswordFailed);
}
}
function resetPasswordSuccess(data, status) {
$window.location.href = '/';
}
function resetPasswordFailed(data) {
2016-05-14 07:34:54 +02:00
vm.hasError = true;
vm.errorMessage = data;
console.log('Failed reset password:' + data);
}
2016-05-14 07:34:54 +02:00
function cancel(form) {
if(form) {
form.$setPristine();
}
}
}
})();