/** * Returns true if the current user is not the guest user, * i.e. if he already has logged in with some other user account.<p> * * @return true if the current user is already logged in */ public boolean isLoggedIn() { return !getCmsObject().getRequestContext().getCurrentUser().isGuestUser(); }
/** * Returns true if the current user is not the guest user, * i.e. if he already has logged in with some other user account.<p> * * @return true if the current user is already logged in */ public boolean isLoggedIn() { return !getCmsObject().getRequestContext().currentUser().isGuestUser(); }
/** * Logs a system user in to OpenCms.<p> * * Note that if a login project name is provided, this project must exist, * otherwise the login is regarded as a failure even if the user data was correct.<p> * * @param userName the users name * @param password the password * @param projectName the project to switch to after login (if null project is not switched) * @param redirectUri the URI to redirect to after login (if null the current URI is used) * * @throws IOException in case redirect after login was not successful */ public void login(String userName, String password, String projectName, String redirectUri) throws IOException { login(userName, password, projectName); if (m_loginException == null) { if (redirectUri != null) { getResponse().sendRedirect( OpenCms.getLinkManager().substituteLink(getCmsObject(), redirectUri, null, true)); } else { getResponse().sendRedirect(getFormLink()); } } }
/** * Logs a system user in to OpenCms.<p> * * Note that if a login project name is provided, this project must exist, * otherwise the login is regarded as a failure even if the user data was correct.<p> * * @param userName the users name * @param password the password * @param projectName the project to switch to after login (if null project is not switched) * @param redirectUri the URI to redirect to after login (if null the current URI is used) * * @throws IOException in case redirect after login was not successful */ public void login(String userName, String password, String projectName, String redirectUri) throws IOException { login(userName, password, projectName); if (m_loginException == null) { if (redirectUri != null) { getResponse().sendRedirect( OpenCms.getLinkManager().substituteLink(getCmsObject(), redirectUri, null, true)); } else { getResponse().sendRedirect(getFormLink()); } } }
CmsUser user = getCmsObject().readUser(userName); OpenCms.getSessionManager().checkCreateSessionForUser(user); getCmsObject().loginUser(userName, password, getRequestContext().getRemoteAddress()); if (projectName != null) { getCmsObject().getRequestContext().setCurrentProject(getCmsObject().readProject(projectName)); if (!getCmsObject().getRequestContext().getCurrentProject().isOnlineProject()) { OpenCms.getSessionManager().updateSessionInfo(getCmsObject(), getRequest()); OpenCms.getSessionManager().sendBroadcast(null, loginMessage.getMessage(), user);
/** * Logs a user out, i.e. destroys the current users session, * after that the current page will be redirected to itself one time to ensure that * the users session is truly destroyed.<p> * * @throws IOException if redirect after logout fails */ public void logout() throws IOException { String loggedInUserName = getRequestContext().getCurrentUser().getName(); HttpSession session = getRequest().getSession(false); if (session != null) { session.invalidate(); /* we need this because a new session might be created after this method, but before the session info is updated in OpenCmsCore.showResource. */ getCmsObject().getRequestContext().setUpdateSessionEnabled(false); } // logout was successful if (LOG.isInfoEnabled()) { LOG.info( Messages.get().getBundle().key( Messages.LOG_LOGOUT_SUCCESFUL_3, loggedInUserName, getRequestContext().addSiteRoot(getRequestContext().getUri()), getRequestContext().getRemoteAddress())); } getResponse().sendRedirect(getFormLink()); } }
getCmsObject().loginUser(userName, password, getRequestContext().getRemoteAddress()); if (projectName != null) { getCmsObject().getRequestContext().setCurrentProject(getCmsObject().readProject(projectName));