Search in sources :

Example 1 with UserForm

use of org.openforis.collect.web.controller.UserController.UserForm in project collect by openforis.

the class SessionController method getLoggedUser.

@RequestMapping(value = "user", method = GET)
@ResponseBody
public UserForm getLoggedUser(HttpServletRequest request, HttpServletResponse response) {
    SessionState sessionState = sessionManager.getSessionState();
    User user = sessionState == null ? null : sessionState.getUser();
    if (user == null) {
        HttpResponses.setNoContentStatus(response);
        return null;
    }
    if (sessionState.getLocale() == null) {
        sessionState.setLocale(request.getLocale());
    }
    return new UserController.UserForm(user);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) User(org.openforis.collect.model.User) UserForm(org.openforis.collect.web.controller.UserController.UserForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with UserForm

use of org.openforis.collect.web.controller.UserController.UserForm in project collect by openforis.

the class SessionController method initialize.

@RequestMapping(value = "initialize", method = POST)
@ResponseBody
public UserForm initialize(HttpServletRequest request) {
    SessionState sessionState = sessionManager.getSessionState();
    User user = sessionState.getUser();
    sessionState.setLocale(request.getLocale());
    return new UserController.UserForm(user);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) User(org.openforis.collect.model.User) UserForm(org.openforis.collect.web.controller.UserController.UserForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

User (org.openforis.collect.model.User)2 UserForm (org.openforis.collect.web.controller.UserController.UserForm)2 SessionState (org.openforis.collect.web.session.SessionState)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2