i'm frustrated!!!!

my velocity login app still does not work ... i am able to login now,
but if i login with a wrong username/password the index.vm is shown ...
i would expect login.vm to be shown again ...

here is my LoginUser.java

package org.test.login.modules.actions;

import org.apache.velocity.Context;

import org.apache.turbine.modules.actions.VelocityAction;
import org.apache.turbine.om.security.User;
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.security.TurbineSecurity;
import org.apache.turbine.services.resources.TurbineResources;
import org.apache.turbine.util.security.TurbineSecurityException;

public class LoginUser extends VelocityAction
{
    public void doLogin(RunData data, Context context)
        throws Exception
    {
        // This prevents a db hit on second Action call during page
        // generation.  Turbine removes everything from the Session
        // before calling this method, so in this case we should
        // continue on with the Login procedure.

        if ( data.getUserFromSession() != null )
        {
            return;
        }

        String username = data.getParameters().getString ( "username",
"" );
        String password = data.getParameters().getString ( "password",
"" );

        User user = null;
        try
        {
            // Authenticate the user and get the object.
            user = TurbineSecurity.getAuthenticatedUser( username,
password );

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

            // Mark the user as being logged in.
            user.setHasLoggedIn(new 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();
        }
        catch ( TurbineSecurityException e )
        {
            System.out.println(e.getMessage());
            data.setMessage(TurbineResources.getString("login.error"));
            // Retrieve an anonymous user.
            data.setUser (TurbineSecurity.getAnonymousUser());
            setTemplate (data,
TurbineResources.getString("template.login"));
        }
    }

    /**
     * This is used in the event that doLogin above fails.
     */
    public void doPerform(RunData data, Context context)
        throws Exception
    {
        data.setMessage("Can't find the button!");
        // Retrieve an anonymous user.
        data.setUser (TurbineSecurity.getAnonymousUser());
        setTemplate (data,
TurbineResources.getString("template.login"));
    }
}


in TR.properties

template.login = login.vm

please help!!!!




------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to