signin.js 1.1 KB

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. /* Controllers */
  3. // signin controller
  4. app.controller('SigninFormController', ['$scope', '$http', '$state', 'md5', function ($scope, $http, $state, md5) {
  5. var username = getQueryString('username');
  6. $scope.user = {username: username};
  7. $scope.authError = null;
  8. $scope.login = function () {
  9. $scope.authError = null;
  10. // Try to login
  11. $http.post('/manager/login', {username: $scope.user.username, password: md5.createHash($scope.user.password)})
  12. .then(function (response) {
  13. var data = response.data;
  14. if (data.result == 1) {
  15. // $state.go('app.ad.manage');
  16. window.location.href = "./index.html?t=" + new Date().getTime() + "";//todo 防止切换用户没有刷新当前用户数据 或许有更好的方案
  17. } else {
  18. $scope.authError = data.description;
  19. }
  20. }, function (x) {
  21. $scope.authError = '服务器异常';
  22. });
  23. };
  24. }])
  25. ;