2
在我的应用程序正在维护的URL给客户分离像如何避免登录,如果已经在角JS
myapp.localhost.com/#/customer1 myapp.localhost.com/#/customer2
登录现在说客户1登录。然后在相同的浏览器,但在其他标签customer2输入他的网址。在这一点上,我想避免customer2登录,当他点击url时,我想再次登录时给customer1 url。
我已经使用了下面的代码。
.factory('authService', function ($rootScope, $state, $auth, $location, $stateParams) {
return {
isLoggedin: function() {
console.log($auth.isAuthenticated());
if (!$auth.isAuthenticated()) {
if($rootScope.currentUser.accessLevel == '1')
{
$rootScope.currentUser = null;
$location.path('/admin');
}
else
{
$rootScope.currentUser = null;
//$state.go('customer',{'customerTag' : localStorage.getItem('customerTag')});
$location.path("/"+localStorage.getItem('customerTag'));
}
return true;
}
}
};
})
.run(function($rootScope, $state, $stateParams, $location, $auth) {
$rootScope.$state = $state;
$rootScope.$on('$stateChangeStart', function(event, toState) {
});
});
请建议的解决方案
要澄清 - 你想要user1登录,user2使用一个新的标签,你希望他们获得登录屏幕。当user1回到他们的标签时,他们仍然登录,而user2仍然有登录屏幕?如果是这种情况,请考虑将验证令牌保存在内存中或localStorage中,但使用唯一密钥将它们分开。 – ioneyed
否。如果用户1在customer1的一个选项卡中登录url并登录。然后在另一个选项卡点击customer2的url的同一个用户现在在这种情况下,我不想让他显示customer2的登录屏幕我想向他展示customer1的屏幕已经登录 –