diff --git a/client/js/app.js b/client/js/app.js index 1602e65..a26e0ec 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -24,7 +24,7 @@ mainApp.config(['$routeProvider', function($routeProvider){ templateUrl: 'partials/image/image.html', controller: 'imageCtrl' }).otherwise({ - redirectTo: '/home' + redirectTo: '/' }); }]); diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js old mode 100644 new mode 100755 index 2b355b1..3332a10 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -9,16 +9,31 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I var callMeAfterPullData=function(data){ $scope.machines=Compute.getData().machines; Loading.stop(); - }; - - + } + + ; + if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ + Loading.start(); + Compute.pullData(callMeAfterPullData); + } + else{ + if(Identity.isAlreadyLogin()){ + callMeAfterPullData(); + } + } + + + Image.getImages(function(){}); + + + $scope.raiseShowMachineDetailsEvent=function(id){ var callback=function(){ Loading.stop(); var data=Compute.getData(); $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); - + } Loading.start(); Compute.pullMachines(callback); diff --git a/server/config.inc.php b/server/config.inc.php index 9767c72..636ee5e 100644 --- a/server/config.inc.php +++ b/server/config.inc.php @@ -5,6 +5,7 @@ $config["modules_enabled"] = ""; $config["urlAuth"] = "http://148.60.11.31:5000/v3"; + $config["tokenTime"] = 60 //miunte = 60 //miuntess ?> diff --git a/server/core/App.php b/server/core/App.php index d35ccc0..e3c9c22 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -37,6 +37,10 @@ class App{ } + public function checkToken(){ + $this->tokenClass->checkToken(); + } + public function getLibClass($service){ switch($service){ diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index bdae8a6..028226a 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -49,6 +49,12 @@ class genTokenOptions $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter'])); } } + + public function checkToken(){ + + return $this->backup['time'] > time(); + + } public function genIdentityToken(){ $options = $this->optionsGlobal['Common']; @@ -271,6 +277,7 @@ class genTokenOptions $path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"]; //error_log(print_r($path, true), 0); file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved'])); + $this->backup['time'] = $token['time']; $this->backup["roles"] = $token["roles"]; $this->backup["project"] = $token['saved']["project"]["name"]; $this->backup["user"] = $token["user"]; @@ -284,7 +291,7 @@ class genTokenOptions public function loadBackup($back){ $backup = unserialize($back); - + $this->backup['time'] = $backup['time']; $this->backup["roles"] = $backup["roles"]; $this->backup["project"] = $backup["project"]; $this->backup["user"] = $backup["user"]; @@ -343,6 +350,7 @@ class genTokenOptions $tokenSerialized["user"]["name"] = serialize($token->user->name); $tokenSerialized["token"]["issued"] = serialize($token->issued); $tokenSerialized["token"]["id"] = serialize($token->id); + $tokenSerialized['time'] = time()+$config['tokenTime']*60; return $tokenSerialized; } diff --git a/server/index.php b/server/index.php index 31feb08..4e9c82b 100755 --- a/server/index.php +++ b/server/index.php @@ -22,7 +22,7 @@ $App->deauthenticate(); $App->show(); - }else{ + }else if($App->checkToken()){ switch($task) { case "identity": @@ -54,6 +54,9 @@ break; } + }else{ + $App->setOuptut("Error", "Token Invalide"); + $App->show(); }