Preventing to visit the login page if the user is logged in
Change-Id: I7e3fe159300e4a29b3b9f5203b3bc6438a40148c
diff --git a/src/app/core/login/login.ts b/src/app/core/login/login.ts
index c091e43..ac0da82 100644
--- a/src/app/core/login/login.ts
+++ b/src/app/core/login/login.ts
@@ -13,6 +13,11 @@
private $state: angular.ui.IStateService,
private ModelSetup: IXosModelSetupService
) {
+
+ if (this.authService.isAuthenticated()) {
+ this.$state.go('xos.dashboard');
+ }
+
this.img = this.getImg(StyleConfig.background);
this.loginStyle = {
diff --git a/src/app/core/services/runtime-states.ts b/src/app/core/services/runtime-states.ts
index bc99a8e..652b554 100644
--- a/src/app/core/services/runtime-states.ts
+++ b/src/app/core/services/runtime-states.ts
@@ -7,7 +7,10 @@
this.$get = function($state: ng.ui.IStateService) {
return {
addState: function(name: string, state: IXosState) {
- $stateProvider.state(name, state);
+ // prevent to add multiple time the same state
+ if (!$state.get(name)) {
+ $stateProvider.state(name, state);
+ }
}
};
};