struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg V Alexeev <go...@penza.net>
Subject Re: Redirecting to login page
Date Fri, 06 Jul 2001 17:39:43 GMT
Hello O'Reilly,

You can check it in Action. Create base SecureAction with check of
login -

public class SecureAction extends Action {

       ActionForward securePerform( ... ) {
                     return loginForward;
       }

       ActionForward perform ( ... ) {

                     if( check user - is logged in? ) {
                       return securePerform( ... );
                     } else {
                       return loginForward;
                     }
       
       }

}

public class TransactionAction extends SecureAction {

       ActionForward securePerform( ... ) {
                     // some stuff here
                     return nativeForward;
       }

}

Friday, July 06, 2001, 8:31:40 PM, you wrote:

ORJ> Hi,
ORJ> I have overridden the processActionPerform method to cause the user to be
ORJ> redirected to a login page if they are entering a "closed" area and have not
ORJ> previously loggged in.  The code below shows my initial attempt.  What is
ORJ> the accepted way of doing this?  I assume there must be a cleaner way.

ORJ>       boolean isClosedArea = portalMapping.getIsClosedArea();

ORJ>       String userName = (String)session.getAttribute("USERNAME");

ORJ>       if ( isClosedArea  && (userName == null || userName == "") )
ORJ>       {
ORJ>         // store requestPath so that we can use it when log in is successful
ORJ>         session.setAttribute("REQUEST_PATH", mapping.getPath());

ORJ>         return new ActionForward("/loginpage.do");
ORJ>       }
ORJ>       else
ORJ>       {
ORJ>         // If REQUEST_PATH is set, then this action was dynamically inserted
ORJ> before
ORJ>         // original request.  Make sure we redirect to original request when
ORJ>         // action completes.
ORJ>         String  requestPath=(String)session.getAttribute("REQUEST_PATH");
ORJ>         if ( requestPath != null && requestPath != "" )
ORJ>         {
ORJ>           session.setAttribute("REQUEST_PATH", "");

ORJ>           super.processActionPerform(action,mapping, formInstance, request,
ORJ> response);
ORJ>           return new RedirectingActionForward(requestPath + ".do");
ORJ>         }

ORJ>         return super.processActionPerform(action,mapping, formInstance,
ORJ> request, response);
ORJ>       }

ORJ> Thanks, 

ORJ> John O'Reilly
ORJ> Traventec

ORJ> Phone:  +353 91 518786
ORJ> Fax:      +353 91 525056
ORJ> Email:    john.oreilly@traventec.com
ORJ> www.traventec.com





-- 
Best regards,
 Oleg                            mailto:gonza@penza.net



Mime
View raw message