| .. | .. |
|---|
| 3 | 3 | |
|---|
| 4 | 4 | var app = angular.module('securis'); |
|---|
| 5 | 5 | |
|---|
| 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) { |
|---|
| 8 | 8 | |
|---|
| 9 | + |
|---|
| 9 | 10 | $('#username').focus(); |
|---|
| 10 | 11 | |
|---|
| 11 | 12 | $scope.submit = function() { |
|---|
| .. | .. |
|---|
| 21 | 22 | }) |
|---|
| 22 | 23 | }). |
|---|
| 23 | 24 | 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); |
|---|
| 25 | 26 | $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; |
|---|
| 26 | 30 | }). |
|---|
| 27 | 31 | error(function(data, status, headers, config) { |
|---|
| 28 | | - console.error(data + " status: "+ status); |
|---|
| 29 | 32 | if (status === 403 /* forbidden */) { |
|---|
| 30 | 33 | toaster.pop('error', $L.get('Login error'), $L.get('Invalid credentials'), 3000); |
|---|
| 31 | 34 | } else { |
|---|
| 35 | + console.error(data + " status: "+ status); |
|---|
| 32 | 36 | toaster.pop('error', $L.get('Unexpected Login error'), $L.get('Unexpected error HTTP ({0}) accessing to server. Contact with the administrator.', status), 5000); |
|---|
| 33 | 37 | } |
|---|
| 34 | 38 | $('#username').focus(); |
|---|