up: HTTP     index Zimbu documentation

CLASS HTTP.LoginServlet EXTENDS HTTP.Servlet @public

summary

     

Generate a redirect when the user is not logged in.

NEW(func, to) @public  Create a new login servlet, using func to check if the user is logged in and redirect to URL to if not.
$setResponseCode(code) @public  Change the default 301 response code into code.
$setPostHandler(func) HTTP.LoginServlet @public  Set a function to handle POST requests.
$serve(context) bool @public  Handle a redirect request.
 
Inherited from HTTP.Servlet:
$setAllPaths(allPaths) @public  Set whether this Servlet handles all paths.
$addPath(path) @public  Add a path that this servlet will serve for.
$handle(context) bool @public  Check if this servlet wants to serve context.request.
$setMimeType(type) @public  Set the MIME type to be used in the response for this Servlet.
$filter(context) bool @public  Filter context.request, possibly changing context.
 

members (alphabetically)

     

PROC NEW(func<HTTP.Context => bool> func, string to) @public

     

Create a new login servlet, using func to check if the user is logged in and redirect to URL to if not.

The func must return TRUE when the user is already logged in, e.g. by checking a cookie. In that case the Servlet $serve() method will return FALSE.

By default works for all paths except to. Call $setAllPaths(FALSE) and $addPath() to change that.

Remember to add this Servlet before any Servlet that requires login.

FUNC $serve(HTTP.Context context) bool @replace @public

     

Handle a redirect request.

FUNC $setPostHandler(func<HTTP.Context => int> func) HTTP.LoginServlet @public

     

Set a function to handle POST requests.

Redirecting POST request doesn't really work.

The func argument will be invoked when not logged in for a POST request. It must return the HTML status code.

Returns the object for chaining.

PROC $setResponseCode(int code) @public

     

Change the default 301 response code into code.

license

      Copyright 2009 Bram Moolenaar All Rights Reserved.

      Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0