• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Redirect from within Session
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Redirect from within Session


  • Subject: Re: Redirect from within Session
  • From: Mark Morris <email@hidden>
  • Date: Sun, 9 Oct 2005 19:52:49 -0500

An easy and comprehensive solution is to override the Application's pageWithName method. I usually return Main if there is no session or if an "authenticated" session variable is false.

Regards,
Mark


On Oct 9, 2005, at 4:57 PM, Mark Wardle wrote:


On 9 Oct 2005, at 21:28, Colin Shreffler wrote:


I need to forward a user to a Login page if they are not authenticated...

I believe the best way to do this is from within the Session object’s constructor.

1] Check to see if the user is authenticated.
2] If they are NOT, forward them to the Login Page.

How can you do that from within the session object?

 __


Hi.

I use a nested Layout system - with multiple web components nested within other components.

For any component that needs to be protected by username/password, I wrap it in my "CheckCredentials" layout. This layout is defined to have two conditionals. It also embeds the standard header component and the standard project footer. The first conditional checks the session for the "isValidUser" property and if true will show the embedded component. The inverse shows the Login component instead., and the second is the inverse.

I don't whether this is the "right" way, but it works well. The session method isValidUser() is written to merely return a simple boolean based on whether "User" is defined or not. The Login component handles doLogin() which is run when the user clicks the "Login" button after entering their credentials. This checks the username/password from the database using a FetchSpec, and if valid, calls session.setUser().

When the user logs out, the session is destroyed. Thus, for any further page accesses, isValidUser() returns false, all pages return the LoginComponent, and will continue to do so until valid credentials are entered.

Hope this helps. It is certainly simpler than fiddling with page forwarding and actually, involves hardly any coding at all.


-- Dr. Mark Wardle Clinical research fellow and Specialist Registrar in Neurology, C2-B2 link, Cardiff University, Heath Park, CARDIFF, CF14 4XN. UK email: email@hidden email@hidden office: +44(0)2920743454 facsimile: +44(0)2920743798 mob: +44(0)7786196137 home: +44(0)2920216341



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40onpointsoftware.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Redirect from within Session (From: Colin Shreffler <email@hidden>)
 >Re: Redirect from within Session (From: Mark Wardle <email@hidden>)

  • Prev by Date: Re: Redirect from within Session
  • Next by Date: Re: "The WO way"
  • Previous by thread: Re: Redirect from within Session
  • Next by thread: Re: Redirect from within Session
  • Index(es):
    • Date
    • Thread