/**
* =============================================================================
*
* ORCID (R) Open Source
* http://orcid.org
*
* Copyright (c) 2012-2014 ORCID, Inc.
* Licensed under an MIT-Style License (MIT)
* http://orcid.org/open-source-license
*
* This copyright and license information (including a link to the full license)
* shall be included in its entirety in all copies or substantial portion of
* the software.
*
* =============================================================================
*/
package org.orcid.frontend.web.controllers;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.orcid.core.manager.ClientDetailsManager;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller("loginController")
public class LoginController extends BaseController {
@Resource
ClientDetailsManager clientDetailsManager;
@ModelAttribute("yesNo")
public Map<String, String> retrieveYesNoMap() {
Map<String, String> map = new LinkedHashMap<String, String>();
map.put("true", "Yes");
map.put("false", "No");
return map;
}
@RequestMapping(value = { "/signin", "/login" }, method = RequestMethod.GET)
public ModelAndView loginGetHandler(HttpServletRequest request, HttpServletResponse response) {
// in case have come via a link that requires them to be signed out
ModelAndView mav = new ModelAndView("login");
return mav;
}
// We should go back to regular spring sign out with CSRF protection
@RequestMapping(value = { "/signout"}, method = RequestMethod.GET)
public ModelAndView signout(HttpServletRequest request, HttpServletResponse response) {
// in case have come via a link that requires them to be signed out
logoutCurrentUser(request, response);
String redirectString = "redirect:" + orcidUrlManager.getBaseUrl() + "/signin";
ModelAndView mav = new ModelAndView(redirectString);
return mav;
}
@RequestMapping("wrong-user")
public String wrongUserHandler() {
return "wrong_user";
}
@RequestMapping("/session-expired")
public String sessionExpiredHandler() {
return "session_expired";
}
}