-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.tex
58 lines (51 loc) · 1.4 KB
/
router.tex
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
\cgiStatus{200 OK}
\cgiContentType{text/html}
\cgiBody{<!DOCTYPE html>}
\cgiBody{<meta charset=UTF-8>}
\cgiBody{<link rel=icon href="data:,">}
\cgiBody{<title>LaCGI</title>}
\authIfLoggedIn{
\cgiBodyX{<p>Hello, \authGetName!}
\cgiEnd
}
\cgiBody{<p>Not logged in!}
\cgiIfPath{login}{
\cgiIfPOST{
\cgiProcessRequest
\authLogin{
\cgiStatus{303 See Other}
\cgiLocation{/cgi-bin/index}
}{
\cgiHeader{Status}{400 Bad Request}
\cgiBody{Invalid username or password}
\cgiEnd
}
}
\cgiBody{<form action="" method="post">}
\cgiBody{<p><label>Username: <input name="u" autocomplete="username"></label>}
\cgiBody{<p><label>Password: <input name="p" type="password" autocomplete="current-password"></label>}
\cgiBody{<p><button>Login</button>}
\cgiBody{</form>}
\cgiEnd
}
\cgiIfPath{signup}{
\cgiIfPOST{
\cgiProcessRequest
\authSignup{
\cgiStatus{303 See Other}
\cgiLocation{/cgi-bin/index}
}{
\cgiHeader{Status}{400 Bad Request}
\cgiBody{Invalid username or password}
\cgiEnd
}
}
\cgiBody{<form action="" method="post">}
\cgiBody{<p><label>Username: <input name="u" autocomplete="username"></label>}
\cgiBody{<p><label>Password: <input name="p" type="password" autocomplete="new-password"></label>}
\cgiBody{<p><button>Signup</button>}
\cgiBody{</form>}
\cgiEnd
}
\cgiBody{<p><a href="/cgi-bin/index/login">Login</a>}
\cgiBody{<p><a href="/cgi-bin/index/signup">Signup</a>}