Example usage for javax.servlet.http HttpServletRequest logout

List of usage examples for javax.servlet.http HttpServletRequest logout

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest logout.

Prototype

public void logout() throws ServletException;

Source Link

Document

Establish null as the value returned when getUserPrincipal, getRemoteUser, and getAuthType is called on the request.

Usage

From source file:org.structr.web.auth.HttpAuthenticator.java

@Override
public void doLogout(HttpServletRequest request) {

    final App app = StructrApp.getInstance();

    try {//w  ww.  j  av a  2  s. com

        app.beginTx();

        Principal user = getUser(request, false);
        if (user != null) {

            user.setProperty(Principal.sessionId, null);
        }

        HttpSession session = request.getSession(false);

        if (session != null) {
            session.invalidate();
        }

        request.logout();

        app.commitTx();

    } catch (Exception ex) {

        logger.log(Level.WARNING, "Error while logging out user", ex);

    } finally {

        app.finishTx();
    }
}

From source file:ru.simplgroupp.rest.api.service.UserSettingsService.java

/**
 * ??   ?  ,   /* w w w . ja v  a 2s .c  o  m*/
 *
 * @param profileData  ?
 * @param user         
 * @return   ? ? ,  ??? ?
 */
public String saveProfileData(ProfileData profileData, Users user, HttpServletRequest request)
        throws PeopleException, ParseException, KassaException, ServletException {
    String error = checkSmsCode(profileData.getSmsCode());
    if (error != null) {
        throw new PeopleException(error);
    }

    boolean passwordChaged = userDataService.savePasswordData(profileData.getPasswordData(), user);
    boolean emailChanged = userDataService.saveEmail(profileData.getMainData(), user);
    boolean phoneChanged = userDataService.savePhone(profileData.getMainData(), user);

    if (passwordChaged || emailChanged) {
        request.logout();
    }

    return "OK";
}