From 441c660af706fd3c6d0e06b36b8f25a808fcdf5f Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Fri, 17 Jan 2014 17:35:50 +0000
Subject: [PATCH] #396 feature - Added security management methods for REST API

---
 securis/src/main/resources/static/js/main.js |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/securis/src/main/resources/static/js/main.js b/securis/src/main/resources/static/js/main.js
index 14521b6..58a7a9b 100644
--- a/securis/src/main/resources/static/js/main.js
+++ b/securis/src/main/resources/static/js/main.js
@@ -67,11 +67,20 @@
 	m.controller('MainCtrl', ['$scope', '$http', '$location', '$L', '$store',
 	                             function($scope, $http, $location, $L, $store) {
 		
+		$location.path('/login');
 		if ($store.get('token') != null) {
-			$http.defaults.headers.common['X-SECURIS-TOKEN'] = $store.get('token'); 
-			$location.path('/licenses');
-		} else {
-			$location.path('/login');
+			
+			$http.get('/check', {
+				headers: {
+					'X-SECURIS-TOKEN': $store.get('token')
+				}
+			}).success(function(data) {
+				if (data.valid) {
+					$http.defaults.headers.common['X-SECURIS-TOKEN'] = $store.get('token'); 
+					$location.path('/licenses');
+					$store.set('user', data.user);
+				}
+			});
 		}
 		
 		$scope.logout = function() {

--
Gitblit v1.3.2