Sign in attempts can be automatically handled using the web.auth module's handlers. The SignInHandler
object takes two parameters, session and manager which should be valid AuthSession
and AuthManager
objects respectively.
The SignInHandler
object has one method handle() which returns a form if there is a problem or None
if the user has been signed in. The SignInHandler
object has one attribute, status
which is a constant specifying the current sign in status.
Here is an example.
# Try to login import web.auth.handler.signIn signInHandler = web.auth.handler.signIn.SignInHandler( session = authSession, manager = authManager, ) form = signInHandler.handle() if form: # Display the error form print '<html><body><h1>Please Sign In</h1>%s<p>%s</p></body></html>'%form else: # We have just signed in print 'Signed in successfully'