UNPKG

unserver-unify

Version:

54 lines (53 loc) 1.79 kB
'use strict'; angular.module('bamboo.mystudy').controller('PasswordCtrl', function($scope, ApiService, CommonService, $state, formService, $filter, $timeout) { var _self = this; _self.pwdchange = function() { $scope.wrongpwd = false; } _self.newPwdchange = function() { _self.usedPwd = false; } $scope.savePassword = function(isvalid) { $scope.passworksubmitted = true; if (!isvalid) { $scope.shaking = true; $timeout(function() { $scope.shaking = false; }, 500); return; } // if ($scope.password.oldp == $scope.password.newp) { // $scope.passworderr = $filter('trans')({ // eng: 'new password MUST not be same as your current password!', // chn: '新密码不能和老密码相同!' // }); // return; // } // if ($scope.password.newp != $scope.password.newp2) { // $scope.passworderr = $filter('trans')({ // eng: 'Entered two different new password, please re-enter', // chn: '两次新密码输入不同,请确认后重新输入' // }); // return; // } //$scope.passworksubmitted = false; ApiService.put('/password', $scope.password).then(function(result) { if (result.data.success) { CommonService.showNoBlockInfo('Update Successful!'); $state.reload(); } else { $scope.error = result.data.error; if (result.data.error == 'Used Password!') { _self.usedPwd = true; } if (result.data.error == 'Wrong Password') { $scope.wrongpwd = true; } $scope.shaking = true; $timeout(function() { $scope.shaking = false; }, 500); } }); } });