您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

login.controller.js 1.0KB

1234567891011121314151617181920212223242526272829303132
  1. angular.module('app')
  2. .controller('LoginController', ['$scope', '$state', 'luticateAuthUsers', 'luticateAuthCache',
  3. function($scope, $state, luticateAuthUsers, luticateAuthCache) {
  4. $scope.username = "";
  5. $scope.password = "";
  6. $scope.errorString = null;
  7. var promiseLogin = {
  8. id: "promiseLogin",
  9. loaderGroups: ["loginForm"]
  10. };
  11. var user = luticateAuthCache.getUser();
  12. if (user != null) {
  13. $state.go('home');
  14. return;
  15. }
  16. $scope.login = function()
  17. {
  18. $scope.errorString = null;
  19. luticateAuthUsers.login({username: $scope.username, password: $scope.password}, promiseLogin)
  20. .then(function(user)
  21. {
  22. $state.go('home');
  23. }, function(error)
  24. {
  25. $scope.errorString = error.Data;
  26. });
  27. };
  28. }
  29. ]);