1234567891011121314151617181920212223242526272829303132 |
- angular.module('luticate')
- .controller('LoginController', ['$scope', '$state', 'luticateAuthUsers', 'luticateAuthCache',
- function($scope, $state, luticateAuthUsers, luticateAuthCache) {
- $scope.username = "";
- $scope.password = "";
- $scope.errorString = null;
-
- var promiseLogin = {
- id: "promiseLogin",
- loaderGroups: ["loginForm"]
- };
-
- var user = luticateAuthCache.getUser();
- if (user != null) {
- $state.go('home');
- return;
- }
-
- $scope.login = function()
- {
- $scope.errorString = null;
- luticateAuthUsers.login({username: $scope.username, password: $scope.password}, promiseLogin)
- .then(function(user)
- {
- $state.go('home');
- }, function(error)
- {
- $scope.errorString = error.Data;
- });
- };
- }
- ]);
|