Sfoglia il codice sorgente

Move login/register redirect to AuthService

pull/1/head
Jack 6 anni fa
parent
commit
0d2239d4e0
Firmato da: foltik <jack@foltz.io> ID Chiave GPG: 303F88F996E95541
5 ha cambiato i file con 5 aggiunte e 11 eliminazioni
  1. +3
    -0
      public/js/services/AuthSvc.js
  2. +0
    -5
      public/js/shimapan-panel/controllers/NavCtrl.js
  3. +1
    -3
      public/js/shimapan/components/LoginComp.js
  4. +0
    -2
      public/js/shimapan/components/RegisterComp.js
  5. +1
    -1
      public/views/panel.html

+ 3
- 0
public/js/services/AuthSvc.js Vedi File

@@ -37,10 +37,12 @@ angular.module('AuthSvc', []).service('AuthService', ['$http', '$window', functi
data: user
}).then(function(res) {
saveToken(res.data.token);
$window.location.href = '/home';
})
};
this.logout = function() {
$window.localStorage.removeItem('shimapan-token');
$window.location.href = '/';
};
this.isLoggedIn = function() {
var payload = decodeToken(getToken());
@@ -61,6 +63,7 @@ angular.module('AuthSvc', []).service('AuthService', ['$http', '$window', functi
data: user
}).then(function(res) {
saveToken(res.data.token);
$window.location.href = '/home';
});
};



+ 0
- 5
public/js/shimapan-panel/controllers/NavCtrl.js Vedi File

@@ -4,11 +4,6 @@ angular.module('NavCtrl', ['AuthSvc']).controller('NavController', ['$scope', '$
$scope.currentScope = AuthService.currentScope();
$scope.logout = AuthService.logout;

$scope.goLogout = function() {
$scope.logout();
$window.location.href = '/';
};

$scope.hasPermission = function(permission) {
if (!$scope.currentScope) return false;
return $scope.currentScope.indexOf(permission) !== -1;


+ 1
- 3
public/js/shimapan/components/LoginComp.js Vedi File

@@ -5,9 +5,7 @@ angular.module('LoginComp', ['AuthSvc']).component('loginComponent', {
AuthService.login({
username: $scope.username,
password: $scope.password
}).then(function () {
alert('Logged In');
});
}
};
}]
});

+ 0
- 2
public/js/shimapan/components/RegisterComp.js Vedi File

@@ -6,8 +6,6 @@ angular.module('RegisterComp', ['AuthSvc']).component('registerComponent', {
username: $scope.username,
password: $scope.password,
invite: $scope.invite
}).then(function () {
alert('Registered');
});
};
}]

+ 1
- 1
public/views/panel.html Vedi File

@@ -27,7 +27,7 @@
<li><a href="/panel/invites" ng-class="{active: $state.$current.name=='/panel/invites'}">Invites</a></li>
<li ng-hide="!hasPermission('users.view')"><a href="/panel/users" ng-class="{active: $state.$current.name=='/panel/users'}">Users</a></li>
<li><a href="/panel/stats" ng-class="{active: $state.$current.name=='/panel/stats'}">Statistics</a></li>
<li><a href="" ng-click="goLogout()">Logout</a></li>
<li><a href="" ng-click="logout()">Logout</a></li>
</ul>
</div>
<div class="content isOpen" ng-class="{isOpen: open}">


Loading…
Annulla
Salva