Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
cgilua/examples/check.lua
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
28 lines (23 sloc)
761 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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 | |