[Seaside] Autologout implementation
Stefan Schmiedl
s at xss.de
Sun Apr 27 12:10:28 UTC 2008
How would you implement automatic logout after a given period of
inactivity?
The app is running in a workshop, where a bunch of people use the same
machine to access their scheduled tasks and other stuff. They will often
leave "their" last page on the screen, so the goal donor requested an
automated reload of the starting page.
I did this for another app (in IOWA on Ruby) by meta-refreshing to the
"/logout" page, which in turn expired the session and redirected to the
starting page.
Below is what I came up with in Seaside. This decoration is
autmatically added to the pages if the users are in the autologout
category.
Has anybody a better idea for this?
Thanks,
s.
Smalltalk.HS defineClass: #AutoLogoutDecoration
superclass: #{Seaside.WADecoration}
indexedType: #none
private: false
instanceVariableNames: 'delay '
classInstanceVariableNames: ''
imports: ''
category: ''!
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
!HS.AutoLogoutDecoration class methodsFor: 'instance creation'!
delay: seconds
^(self new) delay: seconds;
yourself! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
!HS.AutoLogoutDecoration methodsFor: 'updating'!
updateRoot: root
root redirectTo: self urlForExpiry asString
delay: self delay!
urlForExpiry
Continuation currentDo: [:cc | ^self session actionUrlForContinuation: cc].
(self session) expire;
redirect! !
!HS.AutoLogoutDecoration methodsFor: 'accessing'!
delay
^delay!
delay: anObject
delay := anObject! !
More information about the seaside
mailing list