Skip to content
Snippets Groups Projects
Commit 32512a30 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

logout works

parent 3edc9c95
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,6 @@ The API documentation is available at `<BASE URL>/swagger-ui.html`. A JSON versi
## BUGS
* Logout does not work;
* In the profile view, we shouldn't see the '+' between firstname and lastname;
* Export PDF;
......
......@@ -151,6 +151,7 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
String userJSON = mapper.writeValueAsString(getUser(principal));
Cookie cookie = new Cookie("user", URLEncoder.encode(userJSON, "UTF-8"));
cookie.setPath("/");
cookie.setMaxAge(3600);
response.addCookie(cookie);
} catch (JsonProcessingException e) {
e.printStackTrace();
......@@ -160,6 +161,15 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
return principal;
}
@RequestMapping("/logout")
public void logout(HttpServletResponse response) {
Cookie cookie = new Cookie("user", null);
cookie.setPath("/");
cookie.setMaxAge(0);
response.addCookie(cookie);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// @formatter:off
......
/**
* Created by Michael DESIGAUD on 11/08/2015.
*/
angular.module('chuvApp.header').controller('HeaderController', ['$scope', '$translate', '$translatePartialLoader', '$state', 'tmhDynamicLocale', 'User','$rootScope',
function ($scope, $translate, $translatePartialLoader, $state, tmhDynamicLocale, User,$rootScope) {
$translatePartialLoader.addPart('header');
$translate.refresh();
/**
* Change language event
* @param lang new lang
*/
$scope.onChangeLanguage = function (lang) {
$translate.use(lang);
tmhDynamicLocale.set(lang);
};
/**
* Is current language
* @param languageKey language key
* @return {boolean} true if language is the same
*/
$scope.isCurrentLanguage = function (languageKey) {
return $translate.use() === languageKey;
};
/**
* Search method event
*/
$scope.search = function () {
$state.go('search');
};
$scope.logout = function(){
User.removeCurrent();
$state.go('login');
$rootScope.user = null;
};
}]);
\ No newline at end of file
/**
* Created by Michael DESIGAUD on 11/08/2015.
*/
angular.module('chuvApp.header').controller('HeaderController', ['$scope', '$translate', '$translatePartialLoader', '$state', 'tmhDynamicLocale', 'User','$rootScope','$http',
function ($scope, $translate, $translatePartialLoader, $state, tmhDynamicLocale, User,$rootScope, $http) {
$translatePartialLoader.addPart('header');
$translate.refresh();
/**
* Change language event
* @param lang new lang
*/
$scope.onChangeLanguage = function (lang) {
$translate.use(lang);
tmhDynamicLocale.set(lang);
};
/**
* Is current language
* @param languageKey language key
* @return {boolean} true if language is the same
*/
$scope.isCurrentLanguage = function (languageKey) {
return $translate.use() === languageKey;
};
/**
* Search method event
*/
$scope.search = function () {
$state.go('search');
};
$scope.logout = function(){
$http.get("/logout");
User.removeCurrent();
$state.go('login');
$rootScope.user = null;
};
}]);
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment