File: check.lua

package info (click to toggle)
lua-cgi 6.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 956 kB
  • sloc: javascript: 2,216; makefile: 25
file content (28 lines) | stat: -rwxr-xr-x 761 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- Checking script example
-- Assumes that the login form will use two fields called username and pass

local username = cgilua.POST.username
local pass = cgilua.POST.pass
local logged, err, logoutURL

if cgilua.authentication then
    logged, err = cgilua.authentication.check(username, pass)
    username = cgilua.authentication.username() or ""
    logoutURL = cgilua.authentication.logoutURL()
else
    logged = false
    err = "No authentication configured!"
    username = ""
end

if logged and username then
	cgilua.redirect(cgilua.authentication.refURL())
else
    err = err or ""

	cgilua.htmlheader()
	cgilua.lp.include ("login.lp", {
        logged = logged, errorMsg = err, username = username,
        cgilua = cgilua, logoutURL = logoutURL})
end