RE: user is nulled out on login attempt

"Shaw, Nathan (HQ-LD070)[InDyne, Inc]" <[email protected]>
Newsgroups gmane.comp.jakarta.turbine.user
Message-ID <[email protected]>
Hi Peter,

We are actually using 2.1. I know we should upgrade, but we are planning a complete revamp of the app in 6 months.

I was actually looking at the SessionValidator class when your email arrived. However, I am not sure where to begin in trying to use it. According to the docs, "This action is special in that it should only be executed by the Turbine servlet." So, I guess I would have to extend it and then set the value of that class in my TRProps file?

Thanks for the help.

--Nathan


-----Original Message-----
From: Peter Courcoux [mailto:[email protected]]
Sent: Thu 1/31/2008 8:56 AM
To: Turbine Users List
Subject: Re: user is nulled out on login attempt
 
Hi Nathan,

I assume that you are using Turbine 2.3.x.

I may be wrong and I don't have the code to hand at the moment, but I 
suspect that you might need to look at the SessionValidator which is 
called before you get to the login page.

The SessionValidator is pluggable if you need to modify it.

I hope that this helps.

Regards,

Peter

Shaw, Nathan (HQ-LD070)[InDyne, Inc] wrote:
> Hi all,
> 
> I am writing my own login action and need to be able to check to see if a user is already logged in when the action is called. If they are, I want to skip the login stuff to preserve their session. However, every single time that the login action is called, the User object is coming back NULL.
> 
> Here is a code snippet. Does anyone have any idea WHY the user is coming back NULL? I assume something is happening in Turbine somewhere that wipes the User on a login attempt or something?
> 
> 
> public class OutageCalLoginUser extends LoginUser  {
> 
> public void doPerform( RunData data, Context context) throws Exception {
>     String uname ;
>     String passwd ;
>     
>     System.out.println("doPerform(data, context)");
>     if ( data.getUserFromSession() == null ){
>     	System.out.println("user from session is null");
>     }else{
>     	System.out.println("user from session is NOT null");
>     }
>     
>     if(data.getUser() == null){
>     	System.out.println("user is null");
>     }else{
>     	System.out.println("user is NOT null");
>     	if(data.getUser().hasLoggedIn()){
>         	System.out.println("user is logged in");
>         }else{
>         	System.out.println("user is NOT logged in");
>         }
>     }
>     
>     
>     if((data.getUser() == null) || (data.getUser() != null && data.getUser().hasLoggedIn() == false)){
>     	
> 	    try {
> 	      SymEncDec enc = SymEncDec.getInstance();
> 	      
> 	      // Username/password = username/pswd coming through front door.
> 	      // User coming from elsewhere will have neither username nor pswd.
> 	      String username = data.getParameters().get("username");
> 	      String pswd = data.getParameters().get("password");
> 	
> 	      // If username exists, user came in the front door.
> 	      if (username != null && username.length()>0) {
> 	    	  uname = username;
> 	    	  passwd = pswd;
> 	      }else {
> 	          uname = "guest";
> 	          String encryptedPasswd = TurbineResources.getString("guest.credential");
> 	          passwd = encryptedPasswd;
> 	          //enc.decodeBase64Decrypt(encryptedPasswd);
> 	      }
> 	      // Log the user in
> 	      doLogin(data, uname, passwd);
> 	      
> 	      try {
> 	        Utils.getUserID(data);
> 	      }
> 	      catch (NullPointerException npe) {
> 	        throw new TurbineSecurityException("Bad username or password, I say!");
> 	      }
> 	
> 	    }
> 	    catch ( TurbineSecurityException se ) {
> 	      badUserOrPassword(se, data);
> 	    }
> 	    catch (Exception e) {
> 	      throw new PortalVelocityException(e.getMessage()==null?": "+e.getMessage():e.getMessage(),
> 	        e.getCause()==null?e:e.getCause(), data);
> 	    }
>     
>     }
>   }
> 
> } 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.