Hi - here are two tiny classes (basically 2 methods) implementing:
* logging in a user at the session level (allowing the login to be shared by multiple component)
* the login is form-based (unlike WAAuthenticatedSession)
* the login taps into your existing database of users (ie does not restrict you to a single user as WAAuthenticatedSession does). You need to plug in your own code to tap your db, of course. See #handleLogin
* the login is lazy in that it occurs only when a component asks for 'self session user'. This is easy to change into a session-initial login, see the comment in SeasideLoginSession.
Since it took me a couple of hours to find how to do this in Seaside, I thought I'd spare someone else :) Also, since I'm fairly new to Seaside, comments or criticisms are welcome.
Michal
On Mar 24, 2004, at 9:08 AM, miso.list@auf.net wrote:
- the login is lazy in that it occurs only when a component asks for
'self session user'. This is easy to change into a session-initial login, see the comment in SeasideLoginSession.
That's a neat idea, and shows off Seaside in interesting ways. Thanks. In terms of implementation, though, the manual swapping of root etc seems unnecessarily complex. Couldn't you have done this?
SeasideLoginSession>>user ^ user ifNil: [user := root call: SeasideLogin new]
And then in SeasideLogin>>handleLogin, at the end, instead of directly sending #user: to session, just #answer: the user object.
That's a neat idea, and shows off Seaside in interesting ways. Thanks. In terms of implementation, though, the manual swapping of root etc seems unnecessarily complex. Couldn't you have done this?
SeasideLoginSession>>user ^ user ifNil: [user := root call: SeasideLogin new]
And then in SeasideLogin>>handleLogin, at the end, instead of directly sending #user: to session, just #answer: the user object.
Yes, that's much more elegant. I didn't realise that call/answer could be used at the session level. (To keep your implementation parallel to my algorithm which reproproses a login window on failure, that would presumably be:
SeasideLoginSession>>user ^ user ifNil: [ [user isNil] whileTrue: [user := root call: SeasideLogin new]]
That requires a 'cancel' option to be fully usable, which I haven't had time to put in yet. Should be trivial though.)
Michal
seaside@lists.squeakfoundation.org