Thanks,
trying it out now.
michael
> Hello,
>
> personally i've redefined the LoginAction. Hereafter the code.
> I also changed the settings in the Turbine properties:
>
> action.login=LoginAction
>
> hope this helps
>
>
> package com.wuerth.phoenix.bugtrack.modules.actions;
>
> import org.apache.velocity.context.Context;
>
> import org.apache.turbine.om.security.User;
> import org.apache.turbine.modules.actions.VelocityAction;
> import org.apache.turbine.util.RunData;
> import org.apache.turbine.Turbine;
> import org.apache.turbine.util.security.AccessControlList;
> import org.apache.turbine.util.security.TurbineSecurityException;
> import org.apache.turbine.services.resources.TurbineResources;
> import org.apache.turbine.services.security.TurbineSecurity;
> import com.wuerth.phoenix.bugtrack.om.*;
> import org.apache.turbine.util.ParameterParser;
> import javax.servlet.http.HttpSession;
> import org.apache.turbine.util.CookieParser;
> import java.util.*;
>
> /**
> * Title: Bug tracking system
> * Description: Development of a Bug Tracking and Enhancement request
> system * Copyright: Copyright (c) 2001
> * Company:
> * @author Fabio Daprile
> * @version 1.0
> */
>
> public class LoginAction extends VelocityAction
> {
> public void doPerform( RunData data, Context context ) throws
> Exception {
> String username = data.getParameters().getString ( "username",
> "" ); String password = data.getParameters().getString (
> "password", "" ); User user = null;
> Users myUser = null;
> Vector _users = new Vector();
> ParameterParser _formParams;
> HttpSession _session;
> int _paramsNumber;
> String _tempScreen;
> CookieParser _cp = null;
>
> try
> {
> _formParams = data.getParameters();
> _session = data.getSession();
>
> // Validate session on turbine default user
> user = TurbineSecurity.getAuthenticatedUser
> ( "turbine", "turbine" );
>
> //authenticate user
> myUser = new Users();
> myUser = myUser.getAuthenticadedUser(username, password,
> context);
>
> _cp = data.getCookies();
> _cp.set("passwd", password, 1555200000);
> _cp.set("username", username, 1555200000);
>
> if (myUser != null)
> {
> _formParams.remove("username");
> _formParams.remove("password");
> _formParams.remove("action");
>
> _paramsNumber = _formParams.getInt("ParamsNumber");
> _tempScreen = _formParams.getString("TempScreen");
>
> if (_tempScreen.equals("Login.vm"))
> {
> data.getParameters().clear();
> _tempScreen = "HomePage.vm";
> _formParams.add("tempscreen", _tempScreen);
>
> _formParams.add("paramname1", "mode");
> _formParams.add("paramvalue1", "display");
> _formParams.add("ParamsNumber", "1");
> }
> else
> {
> _formParams.add("TempScreen" ,_tempScreen);
> _formParams.add("ParamsNumber", String.valueOf
> (_paramsNumber));
>
> while(_paramsNumber > 0)
> {
> _formParams.add("paramname" + _paramsNumber,
> _formParams.getString("paramname" + _paramsNumber));
> _formParams.add("paramvalue" + _paramsNumber,
> _formParams.getString("paramvalue" + _paramsNumber));
> _paramsNumber--;
> }
> }
>
> if(myUser != null)
> myUser.setLoggedIn();
>
> // 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();
>
> AccessControlList acl = data.getACL();
> if ( acl == null )
> {
> acl = TurbineSecurity.getACL( data.getUser() );
> _session.setAttribute( AccessControlList.SESSION_KEY,
> (Object)acl );
> }
> data.setACL(acl);
> data.save();
>
> if (myUser.getLastlogintimestamp() != null)
> {
> if (myUser.getLastloginfrom() != null)
> {
> _session.setAttribute("lastlogintime",
> myUser.getLastlogintimestamp());
> _session.setAttribute("lastloginfrom",
> myUser.getLastloginfrom());
> }
> }
> else
> {
> _session.setAttribute("lastlogintime", "");
> _session.setAttribute("lastloginfrom", "");
> }
>
> myUser.setLastlogintimestamp(Calendar.getInstance().getTime());
> myUser.setLastloginfrom(data.getRemoteHost());
> myUser.setModified(true);
> myUser.save();
>
> _session.setAttribute("myUser",myUser);
>
> data.setMessage(TurbineResources.getString("login.welcome"));
> data.setLayoutTemplate("Default.vm");
> this.setTemplate(data, "Index.vm");
> }
> }
> catch (Exception e )
> {
> //System.out.println("passo da qui");
> //e.printStackTrace();
> data.setMessage(TurbineResources.getString("login.error"));
> data.setScreen(TurbineResources.getString("screen.login"));
> }
> }
> }
>
>
>
>
> Quoting Eigen Technology Pty Ltd <[EMAIL PROTECTED]>:
>
>> I am having some difficulties in following the instructions as given
>> in the reply:
>>
>> http://archives.apache.org/eyebrowse/ReadMsg?listName=&msgId=290818
>>
>>
>> >All the problem was that the LoginAction was an extension of
>> >VelocitySecureAction, and this class throws the template without
>> executing the screen java code.
>> >
>> >Now it is an extension of VelocityAction.
>> >
>> >I created a Login.java, (as you suggested) which has to be an
>> extension of VelocityScreen, and not secure as seen for the Action
>> upper and i changed
>> a
>> >piece of code in the IsAuthorized method in my SecureScreen class.
>>
>>
>> 1) Is this new Login.java an extension of VelocityAction or
>> VelocityScreen? It is a bit confusing from the above description.
>>
>> 2) Do I need to change the line:
>>
>> FROM action.login=LoginUser
>> TO action.login=Login
>>
>> in TR.properties as a consquence?
>>
>>
>> >3. in the action of the Login form, set the template to =
>> >$destiation_template and for each parameter add a hidden input field
>> to = the form
>> >
>> >ie
>> >
>> <formmethod="post"action="$ling.setAction("Login").setTemplate
> ($destination_template)">
>> >
>> >#foreach($parameter in $parameters)
>> ><input type=hidden name="$parameter" =
>> >value="$parameters.get($parameter)">
>> >
>> >blah blah...
>> >
>> ></form>
>>
>>
>> 3) I am having problem with the <form ..... etc line.
>>
>> after I typed in the login username and passwd, the URL bar shows:
>>
>> http://ns1.eigentechnology.net:8080/medici/servlet/$link.setAction(
>>
>> and sent me an page not found message.
>>
>> Can anyone give me some more instructions on this please.
>>
>> thanks
>> michael
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <mailto:[EMAIL PROTECTED]>
>> For additional commands, e-mail:
>> <mailto:[EMAIL PROTECTED]>
>>
>
>
>
>
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
>
>
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]> For additional
> commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>