iknb/admin/components/password/password.component.js

39 lines
923 B
JavaScript
Raw Normal View History

2020-07-08 11:56:33 +00:00
'use strict';
angular
.module('sloDialectsAdmin')
.component('password', {
templateUrl: 'components/password/password.template.html',
controller: ['$http', '$location', '$timeout', function PasswordController($http, $location, $timeout) {
var vm = this;
vm.go = go;
vm.username = "";
vm.changePassword = function(){
vm.error = "";
// TODO
$http.put('../api/changePassword', {old_password: vm.old_password, new_password: vm.new_password, new_password_repeat: vm.new_password_repeat}).then(function (result) {
if(result.data.success){
vm.success = result.data.message;
$timeout(function(){
go('/login');
}, 3000);
} else {
vm.error = result.data.message;
}
}, function (error, x) {
vm.error = "Prišlo je do napake pri zahtevi za menjavo gesla.";
});
}
function go(path) {
$location.path(path);
}
}]
});