limitless.controller('Zupit.Limitless.Backend.LoginController', ['$scope', '$rootScope', 'Zupit.Core.AppService', 'Zupit.Identity.AuthService', '$state', '$stateParams', '$translate', function ($scope, $rootScope, app, auth, $state, $stateParams, $translate) { $scope.message = $stateParams.message; $scope.email = ''; $scope.password = ''; $scope.rememberMe = false; $translate('EMAIL').then(function (headline) { $scope._EMAIL = headline; }, function (translationId) { $scope._EMAIL = translationId; }); function checkIfAlreadyLoggedIn(user) { if (user !== null && user!==undefined && user.isAuthenticated) { $state.go($stateParams.name, $stateParams.params); return; } } checkIfAlreadyLoggedIn(app.user); $scope.login = function (event) { event.preventDefault(); app.Loading.show('#loginbox'); auth.login($scope.email, $scope.password, $scope.rememberMe).then(function () { app.Loading.hide('#loginbox'); $state.go($stateParams.name, $stateParams.params); },function() { app.Loading.hide('#loginbox'); }); }; }]);