From 04afd774aecc70dca37559fdd8b9a716829c18cd Mon Sep 17 00:00:00 2001
From: Roberto Sánchez <roberto.sanchez@curisit.net>
Date: Fri, 17 Jan 2014 12:27:16 +0000
Subject: [PATCH] #396 feature - Added LocalStorage support and http interceptor for unauthorized access
---
securis/src/main/resources/static/js/login.js | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/securis/src/main/resources/static/js/login.js b/securis/src/main/resources/static/js/login.js
index 29a7eae..704bdc3 100644
--- a/securis/src/main/resources/static/js/login.js
+++ b/securis/src/main/resources/static/js/login.js
@@ -3,9 +3,10 @@
var app = angular.module('securis');
- app.controller('LoginCtrl', ['$scope', '$http', '$window', '$location', 'toaster', '$L',
- function($scope, $http, $window, $location, toaster, $L) {
+ app.controller('LoginCtrl', ['$scope', '$http', '$location', 'toaster', '$L', '$store',
+ function($scope, $http, $location, toaster, $L, $store) {
+
$('#username').focus();
$scope.submit = function() {
@@ -21,14 +22,17 @@
})
}).
success(function(data, status, headers, config) {
- toaster.pop('success', $L.get('Login successful'), $L.get('User {0} has logged in SeCuris', $scope.username), 1500);
+ toaster.pop('success', $L.get('Login successful'), $L.get('User {0} has logged in application', $scope.username), 1500);
$location.path('/licenses');
+ $store.put('username', $scope.username);
+ $store.put('token', data.token);
+ $http.defaults.headers.common['X-SECURIS-TOKEN'] = data.token;
}).
error(function(data, status, headers, config) {
- console.error(data + " status: "+ status);
if (status === 403 /* forbidden */) {
toaster.pop('error', $L.get('Login error'), $L.get('Invalid credentials'), 3000);
} else {
+ console.error(data + " status: "+ status);
toaster.pop('error', $L.get('Unexpected Login error'), $L.get('Unexpected error HTTP ({0}) accessing to server. Contact with the administrator.', status), 5000);
}
$('#username').focus();
--
Gitblit v1.3.2