(function () {
'use strict';
angular.module('app').controller('accountController', [
'$scope', '$q', '$http', 'ngDialog', 'AuthService', '$window', 'AccountService', 'ngToast', 'MyService',
function ($scope, $q, $http, ngDialog, AuthService, $window, AccountService, ngToast, MyService) {
$scope.clientIdStr = clientIdStr; $scope.clientId= clientId;
AuthService.checkAuthStatus();
refresh();
function refresh() {
AccountService.getProfile().then(function (value) {
$scope.profile = value.data;
console.log($scope.profile);
});
}
$scope.processForm = function (isValid) {
if (!isValid) {
ngToast.create({
className: 'danger',
timeout: 1000,
content: 'Some fields are not properly filled, please check and try again.'
});
}else{
AccountService.resetPassword($scope.data.oldPassword, $scope.data.password, $scope.data.confirmPassword).then(function (value) {
console.log(value);
if(value.status == 200){
ngToast.create({
className: 'success',
timeout: 1000,
content: 'Password has been updated!'
});
refresh();
}
}, function (err) {
ngToast.create({
className: 'danger',
timeout: 1000,
content: 'Old password is not correct!'
});
refresh();
});
}
};
}]);
})();