mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-03-11 11:38:41 +01:00
Better session handling and auto redirect to login upon session expired
This commit is contained in:
parent
137f805e90
commit
b1befb905f
2 changed files with 11 additions and 2 deletions
|
|
@ -125,6 +125,8 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $
|
|||
}
|
||||
},
|
||||
// Perfect! This loads our controllers on demand! :)
|
||||
// Leave this code here because it serves as a valuable example
|
||||
// of how this can be done.
|
||||
/*resolve: {
|
||||
deps : function ($q, $rootScope) {
|
||||
var deferred = $q.defer();
|
||||
|
|
@ -139,7 +141,14 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $
|
|||
},*/
|
||||
onEnter: function($uci, $rootScope){
|
||||
$rootScope.errors.splice(0, $rootScope.errors.length);
|
||||
$uci.$revert();
|
||||
|
||||
// this will touch the session so that it does not expire
|
||||
$rpc.$authenticate().done(function(){
|
||||
$uci.$revert();
|
||||
}).fail(function(){
|
||||
$juci.redirect("login");
|
||||
});
|
||||
|
||||
document.title = $tr(k.replace(/\//g, ".")+".title")+" - "+$tr(gettext("application.name"));
|
||||
},
|
||||
onExit: function($interval){
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@
|
|||
} else {
|
||||
self.$session = result;
|
||||
if(!("data" in self.$session)) self.$session.data = {};
|
||||
console.log("Session: Loggedin! ");
|
||||
//console.log("Session: Loggedin! ");
|
||||
deferred.resolve(result);
|
||||
}
|
||||
}).fail(function err(result){
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue