Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- twPublicApp.controller('PublicLoginCtrl', function ($scope, $http, LoginData, BrowserStorageService, $window, $location) {
- window.changeApiRoot('/api/');
- $scope.username = '';
- $scope.password = '';
- $scope.remember = false;
- $scope.errorMessage = '';
- $scope.authenticating = false;
- if (LoginData.get('SessionToken', null, true) !== null) {
- // Check if still has a valid session
- $scope.authenticating = true;
- LoginData.checkSession(LoginData.get('SessionToken'), LoginData.get('Location'))
- .success(function(data) {
- if (data.Result === true) {
- console.log('User looks to be already logged in... sending on');
- BrowserStorageService.changeStore('localStorage');
- LoginData.set(data);
- //This is the line giving me problems. I've tried these two versions, and a few others, and nothing seems to work properly.
- //window.location.href = '/console#/status';
- $window.location = '/console#/status';
- $scope.authenticating = false;
- } else {
- $scope.authenticating = false;
- LoginData.set({});
- }
- })
- .error(function(jqXHR, textStatus, errorThrown) {
- $scope.authenticating = false;
- LoginData.set({});
- });
- }
- $scope.authenticate = function() {
- $scope.authenticating = true;
- LoginData.authenticate($scope.username, $scope.password, $scope.remember)
- .success(function(data) {
- if (data.Result === true) {
- if ($scope.remember) {
- BrowserStorageService.changeStore('localStorage');
- } else {
- BrowserStorageService.changeStore('sessionStorage');
- }
- LoginData.set(data);
- //Interestingly, this line works perfectly.
- window.location.href = '/console#/status';
- return;
- }
- $scope.authenticating = false;
- })
- .error(function(jqXHR, textStatus, errorThrown) {
- $scope.authenticating = false;
- });
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement