2016-05-10 12:43:52 +02:00
|
|
|
(function() {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular
|
|
|
|
.module('harbor.layout.reset.password')
|
|
|
|
.controller('ResetPasswordController', ResetPasswordController);
|
|
|
|
|
2016-05-19 06:50:32 +02:00
|
|
|
ResetPasswordController.$inject = ['$location', 'ResetPasswordService', '$window', 'getParameterByName'];
|
2016-05-10 12:43:52 +02:00
|
|
|
|
2016-05-19 06:50:32 +02:00
|
|
|
function ResetPasswordController($location, ResetPasswordService, $window, getParameterByName) {
|
2016-05-10 12:43:52 +02:00
|
|
|
var vm = this;
|
|
|
|
vm.resetUuid = getParameterByName('reset_uuid', $location.absUrl());
|
2016-05-14 07:34:54 +02:00
|
|
|
|
|
|
|
vm.reset = reset;
|
2016-05-10 12:43:52 +02:00
|
|
|
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 = '';
|
|
|
|
}
|
|
|
|
|
2016-05-10 12:43:52 +02:00
|
|
|
function resetPassword(user) {
|
2016-05-16 05:41:54 +02:00
|
|
|
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);
|
|
|
|
}
|
2016-05-10 12:43:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function resetPasswordSuccess(data, status) {
|
2016-06-16 08:10:35 +02:00
|
|
|
$window.location.href = '/';
|
2016-05-10 12:43:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function resetPasswordFailed(data) {
|
2016-05-14 07:34:54 +02:00
|
|
|
vm.hasError = true;
|
|
|
|
vm.errorMessage = data;
|
2016-05-10 12:43:52 +02:00
|
|
|
console.log('Failed reset password:' + data);
|
|
|
|
}
|
|
|
|
|
2016-05-14 07:34:54 +02:00
|
|
|
function cancel(form) {
|
|
|
|
if(form) {
|
|
|
|
form.$setPristine();
|
|
|
|
}
|
|
|
|
}
|
2016-05-10 12:43:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
})();
|