checking user logged in

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

checking user logged in

Nick
Hi,

I'd like to flag various pages in my site as being only valid if the user is logged in. I've an action which creates a popup login/registration dialog and ideally I'd like to tie to two together so that pages that are flagged as requiring a user will display the popup login/registration dialog. 
Has anyone developed anything like this before or any thoughts on how to hook into Pier to provide the required behaviour?

Thanks

Nick

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: checking user logged in

Nick
For reference, I've solved this as follows:

For pages requiring a logged-in user:
* I've added a method #gotoLoggedIn: to WAAnchorTag which I use instead of #goto: when linking to pages which assume a logged in user.
* The implementation of #gotoLoggedIn: creates a login/registration command if "self context isLoggedIn not". The command stores the destination structure which is passed to the #gotoLoggedIn: method as a parameter.
* If the login/registration command completes successfully, the destination structure is set in the context.

For actions requiring a logged-in user:
* I've added an extension method #requiresLogin to PRCommand which by default returns false.
* In #onChangeContext: of my derived from PRContentsWidget class, I check to see if (aContext isLoggedIn not and: [aContext command requiresLogin])
* I then set the context command to be my login/registration command and storing the initial command in the login/registration command.
* If the login/registration command completes successfully, the original command is set in the context.

Cheers

Nick

On 17 May 2010 11:44, Nick Ager <[hidden email]> wrote:
Hi,

I'd like to flag various pages in my site as being only valid if the user is logged in. I've an action which creates a popup login/registration dialog and ideally I'd like to tie to two together so that pages that are flagged as requiring a user will display the popup login/registration dialog. 
Has anyone developed anything like this before or any thoughts on how to hook into Pier to provide the required behaviour?

Thanks

Nick


_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki