Project

General

Profile

« Previous | Next » 

Revision 57677

redirect to login after expired ajax calls

View differences:

modules/dnet-orgs-database-application/trunk/src/main/java/eu/dnetlib/organizations/MyAccessDeniedHandler.java
20 20
	private static Logger logger = LoggerFactory.getLogger(MyAccessDeniedHandler.class);
21 21

  
22 22
	@Override
23
	public void handle(final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse, final AccessDeniedException e)
23
	public void handle(final HttpServletRequest req, final HttpServletResponse res, final AccessDeniedException e)
24 24
			throws IOException, ServletException {
25 25

  
26 26
		final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
27 27

  
28 28
		if (auth != null) {
29
			logger.warn(String.format("User '%s' attempted to access the protected URL: %s", auth.getName(), httpServletRequest.getRequestURI()));
29
			logger.warn(String.format("User '%s' attempted to access the protected URL: %s", auth.getName(), req.getRequestURI()));
30 30
		}
31 31

  
32
		httpServletResponse.sendRedirect(httpServletRequest.getContextPath() + "/authorizationRequest");
32
		res.sendRedirect(req.getContextPath() + "/authorizationRequest");
33 33
	}
34 34

  
35 35
}
modules/dnet-orgs-database-application/trunk/src/main/resources/static/resources/html/enrichments.html
55 55
		</div>
56 56
	</div>
57 57
</div>
58
{{xxx}}
modules/dnet-orgs-database-application/trunk/src/main/resources/static/resources/js/organizations.js
97 97
	$scope.vocabularies = {};
98 98

  
99 99
	$http.get('api/vocabularies').then(function successCallback(res) {
100
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
100 101
		$scope.vocabularies = res.data;
101 102
	}, function errorCallback(res) {
102 103
		alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
105 106
	$scope.save = function() {
106 107
		$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
107 108
		$http.post('api/organizations/save', $scope.org).then(function successCallback(res) {
109
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
108 110
//			alert('Organization saved !!!');
109 111
			$location.url('/metadata/1/' + res.data[0]);
110 112
		}, function errorCallback(res) {
......
128 130
	$scope.orgs = {};
129 131
	
130 132
	$http.get('api/organizations/search/' + $routeParams.page + '/' + $routeParams.size + '?q=' + $scope.fieldValue).then(function successCallback(res) {
133
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
131 134
		$scope.orgs = res.data;
132 135
	}, function errorCallback(res) {
133 136
		alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
140 143
	$scope.entries = [];
141 144
	
142 145
	$http.get('api/organizations/browse/countries').then(function successCallback(res) {
146
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
143 147
		$scope.entries = res.data;
144 148
	}, function errorCallback(res) {
145 149
		alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
154 158
	$scope.orgs = [];
155 159
	
156 160
	$http.get('api/organizations/byCountry/' + $routeParams.code + '/' + $routeParams.page + '/' + $routeParams.size).then(function successCallback(res) {
161
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
157 162
		$scope.orgs = res.data;
158 163
	}, function errorCallback(res) {
159 164
		alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
166 171
	$scope.entries = [];
167 172
	
168 173
	$http.get('api/organizations/browse/types').then(function successCallback(res) {
174
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
169 175
		$scope.entries = res.data;
170 176
	}, function errorCallback(res) {
171 177
		alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
180 186
	$scope.orgs = [];
181 187
	
182 188
	$http.get('api/organizations/byType/' + $routeParams.type + '/' + $routeParams.page + '/' + $routeParams.size).then(function successCallback(res) {
189
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
183 190
		$scope.orgs = res.data;
184 191
	}, function errorCallback(res) {
185 192
		alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
206 213
	$timeout(function() { $scope.message = ''; }, 3000)
207 214
		
208 215
	$http.get('api/vocabularies').then(function successCallback(res) {
216
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
217

  
209 218
		$scope.vocabularies = res.data;
210

  
211 219
		$http.get('api/organizations/get?id=' + $routeParams.id).then(function successCallback(res) {
220
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
212 221
			$scope.org = res.data;
213 222
		}, function errorCallback(res) {
214 223
			alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
220 229
	$scope.save = function() {
221 230
		$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
222 231
		$http.post('api/organizations/save', $scope.org).then(function successCallback(res) {
223
			if ($routeParams.msg == 2) { $route.reload(); }
224
			else                       { $location.url('/metadata/2/' + res.data[0]); }
232
			if      ((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
233
			else if ($routeParams.msg == 2)         { $route.reload(); }
234
			else                                    { $location.url('/metadata/2/' + res.data[0]); }
225 235
		}, function errorCallback(res) {
226 236
			alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
227 237
		});
......
244 254
	orgInfoService.getInfo($scope.orgId, function(info) { $scope.info = info; });
245 255
	
246 256
	$http.get('api/vocabularies').then(function successCallback(res) {
257
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
258
		
247 259
		$scope.vocabularies = res.data;
248 260

  
249 261
		$http.get('api/organizations/relations?id=' + $routeParams.id).then(function successCallback(res) {
262
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
250 263
			$scope.rels = res.data;
251 264
		}, function errorCallback(res) {
252 265
			alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
263 276
		$http.put('api/organizations/relations', null, { 
264 277
			'params': { 'from': $scope.orgId, 'to': $scope.newRelation.id, 'type': $scope.newRelType }
265 278
		}).then(function successCallback(res) {
279
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
266 280
			$scope.rels = res.data;
267 281
			$scope.newRelType = '';
268 282
			$scope.newRelation = {};
......
276 290
		$http.delete('api/organizations/relations', { 
277 291
			'params': { 'from': $scope.orgId, 'to': to, 'type': type }
278 292
		}).then(function successCallback(res) {
293
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
279 294
			$scope.rels = res.data;
280 295
//			alert("Relation deleted !!!")
281 296
		}, function errorCallback(res) {
......
286 301
	$scope.search = function(text, page, size) {
287 302
		$scope.orgs = [];
288 303
		$http.get('api/organizations/search/' + page + '/' + size + '?q=' + text).then(function successCallback(res) {
304
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
289 305
			$scope.searchValue = text;
290 306
			$scope.searchOrgs = res.data;
291 307
		}, function errorCallback(res) {
......
304 320
	orgInfoService.getInfo($scope.orgId, function(info) { $scope.info = info; });
305 321
	
306 322
	$http.get('api/vocabularies').then(function successCallback(res) {
323
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
324
		
307 325
		$scope.vocabularies = res.data;
308 326

  
309 327
		$http.get('api/organizations/enrichments?id=' + $routeParams.id).then(function successCallback(res) {
328
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
310 329
			$scope.enrichments = res.data;
311 330
		}, function errorCallback(res) {
312 331
			alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
319 338
	$scope.saveEnrichments = function() {
320 339
		$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
321 340
		$http.post('api/organizations/enrichments', $scope.enrichments).then(function successCallback(res) {
341
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
322 342
			alert('Enrichments updated !!!');
323 343
			$scope.enrichments = res.data;
324 344
		}, function errorCallback(res) {
......
336 356
	orgInfoService.getInfo($scope.orgId, function(info) { $scope.info = info; });
337 357
	
338 358
	$http.get('api/vocabularies').then(function successCallback(res) {
359
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
360
		
339 361
		$scope.vocabularies = res.data;
340 362

  
341 363
		$http.get('api/organizations/conflicts?id=' + $routeParams.id).then(function successCallback(res) {
364
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
342 365
			$scope.conflicts = res.data;
343 366
		}, function errorCallback(res) {
344 367
			alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
351 374
orgsModule.controller('showAllConflictsCtrl', function ($scope, $http) {
352 375
	$scope.conflicts = [];
353 376
	$http.get('api/organizations/conflicts/all').then(function successCallback(res) {
377
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
354 378
		$scope.conflicts = res.data;
355 379
	}, function errorCallback(res) {
356 380
		alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
364 388
	$scope.superAdminMode = superAdminMode();
365 389
	
366 390
	$http.get('api/vocabularies').then(function successCallback(res) {
391
		if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
367 392
		$scope.vocs = res.data;
368 393

  
369 394
		$http.get('api/users').then(function successCallback(res) {
395
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
370 396
			$scope.users = res.data;
371 397
		}, function errorCallback(res) {
372 398
			alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
383 409
	$scope.saveUser = function(user) {
384 410
		$http.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8";
385 411
		$http.post('api/users', user).then(function successCallback(res) {
412
			if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
386 413
			$scope.users = res.data;
387 414
		}, function errorCallback(res) {
388 415
			alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');
......
392 419
	$scope.deleteUser = function(email) {
393 420
		if (confirm("Are you sure ?")) {
394 421
			$http.delete('api/users?email=' + email).then(function successCallback(res) {
422
				if((typeof res.data) == 'string') { alert("Session expired !"); location.reload(true); }
395 423
				$scope.users = res.data;
396 424
			}, function errorCallback(res) {
397 425
				alert('ERROR: ' + res.data.error + ' (' + res.data.message + ')');

Also available in: Unified diff