我在尋找最好的架構解決方案。Angular JS身份驗證維護
我有以下的html:
<body ng-controller="individualFootprintController as $ctrl">
<div ng-hide="$ctrl.authenticated">
<h1>Login</h1>
With Corporate Account: <a href="/login/corporate">click here</a>
</div>
和控制器:
function individualFootprintController($http) {
var self = this;
$http.get("/is_auth").success(function() {
self.authenticated = true;
})
.error(function() {
self.authenticated = false;
}
);
}
問題:
1)這是控制器具有這種邏輯適當的地方嗎?
2)我想要有實際的「is_authenticated」值。如果我只想觸發一次請求,如何才能做到這一點
他使用Cookie認證。 –
在jwt auth scenari中,「我有一個標記」這一事實並不意味着你已經過身份驗證。通過身份驗證更像是「我的令牌有效」,必須經常檢查。 –
如果令牌是隱含的,那麼只需用'true' /'false'標誌替換它即可。是的,直到你嘗試它,你纔會知道你的代幣是否有效。所以當它失敗時,將其無效。 – deceze