Roberto Sánchez
2014-01-17 04afd774aecc70dca37559fdd8b9a716829c18cd
securis/src/main/resources/static/js/login.js
....@@ -3,9 +3,10 @@
33
44 var app = angular.module('securis');
55
6
- app.controller('LoginCtrl', ['$scope', '$http', '$window', '$location', 'toaster', '$L',
7
- function($scope, $http, $window, $location, toaster, $L) {
6
+ app.controller('LoginCtrl', ['$scope', '$http', '$location', 'toaster', '$L', '$store',
7
+ function($scope, $http, $location, toaster, $L, $store) {
88
9
+
910 $('#username').focus();
1011
1112 $scope.submit = function() {
....@@ -21,14 +22,17 @@
2122 })
2223 }).
2324 success(function(data, status, headers, config) {
24
- toaster.pop('success', $L.get('Login successful'), $L.get('User {0} has logged in SeCuris', $scope.username), 1500);
25
+ toaster.pop('success', $L.get('Login successful'), $L.get('User {0} has logged in application', $scope.username), 1500);
2526 $location.path('/licenses');
27
+ $store.put('username', $scope.username);
28
+ $store.put('token', data.token);
29
+ $http.defaults.headers.common['X-SECURIS-TOKEN'] = data.token;
2630 }).
2731 error(function(data, status, headers, config) {
28
- console.error(data + " status: "+ status);
2932 if (status === 403 /* forbidden */) {
3033 toaster.pop('error', $L.get('Login error'), $L.get('Invalid credentials'), 3000);
3134 } else {
35
+ console.error(data + " status: "+ status);
3236 toaster.pop('error', $L.get('Unexpected Login error'), $L.get('Unexpected error HTTP ({0}) accessing to server. Contact with the administrator.', status), 5000);
3337 }
3438 $('#username').focus();