public void doPerform()

in src/java/org/apache/turbine/modules/actions/LoginUser.java [85:155]


    public void doPerform(PipelineData pipelineData)
            throws FulcrumSecurityException
    {
        RunData data = pipelineData.getRunData();
        String username = data.getParameters().getString(CGI_USERNAME, "");
        String password = data.getParameters().getString(CGI_PASSWORD, "");

        if (StringUtils.isEmpty(username))
        {
            return;
        }

        try
        {
        	if (username.equals(security.getAnonymousUser().getName()))
            {
                throw new TurbineException("Anonymous user cannot login");
            }

            // Authenticate the user and get the object.
            User user = security.getAuthenticatedUser(username, password);

            // Store the user object.
            data.setUser(user);

            // Mark the user as being logged in.
            user.setHasLoggedIn(Boolean.TRUE);

            // Set the last_login date in the database.
            user.updateLastLogin();

            // This only happens if the user is valid; otherwise, we
            // will get a valueBound in the User object when we don't
            // want to because the username is not set yet.  Save the
            // User object into the session.
            data.save();

            /*
             * If the setPage("template.vm") method has not
             * been used in the template to authenticate the
             * user (usually Login.vm), then the user will
             * be forwarded to the template that is specified
             * by the "template.home" property as listed in
             * TR.props for the webapp.
             */

        }
        catch (Exception e)
        {
            if (e instanceof DataBackendException)
            {
                log.error(e);
            }

            // Set Error Message and clean out the user.
            data.setMessage(loginError);

            User anonymousUser = security.getAnonymousUser();
            data.setUser(anonymousUser);

            if (StringUtils.isNotEmpty(templateLogin))
            {
                // We're running in a templating solution
                data.setScreenTemplate(templateLogin);
            }
            else
            {
                data.setScreen(screenLogin);
            }
        }
    }