Mercurial Hosting > freedit
annotate src/register.html.luan @ 61:389e5d8e5f8a default tip
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 06 Dec 2022 13:37:25 -0700 |
parents | c57b84f461ae |
children |
rev | line source |
---|---|
3 | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | |
3 local Io = require "luan:Io.luan" | |
4 local Http = require "luan:http/Http.luan" | |
5 local Shared = require "site:/lib/Shared.luan" | |
6 local head = Shared.head or error() | |
7 local header = Shared.header or error() | |
8 local footer = Shared.footer or error() | |
9 local base_url = Shared.base_url or error() | |
6 | 10 local call_mail_api = Shared.call_mail_api or error() |
3 | 11 local Forum = require "site:/lib/Forum.luan" |
12 local forum_title = Forum.title or error() | |
13 local User = require "site:/lib/User.luan" | |
14 | |
15 | |
16 local function page(contents) | |
17 Io.stdout = Http.response.text_writer() | |
18 %> | |
19 <!doctype html> | |
20 <html> | |
21 <head> | |
22 <% head() %> | |
55
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
23 <title><%=forum_title%> - Register</title> |
3 | 24 </head> |
25 <body> | |
26 <% header() %> | |
27 <div content> | |
55
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
28 <h1>Register</h1> |
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
29 <h3>Or Get or Change Password</h3> |
3 | 30 <% |
31 contents() | |
32 %> | |
33 </div> | |
34 <% footer() %> | |
35 </body> | |
36 </html> | |
37 <% | |
38 end | |
39 | |
40 return function() | |
41 local email = Http.request.parameters.email | |
42 if email == nil then | |
43 page(function() | |
44 %> | |
45 <form> | |
55
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
46 <p> |
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
47 <label>Email address</label> |
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
48 <input type="email" name="email" autofocus required> |
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
49 </p> |
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
50 <p><label clickable><input type=checkbox name=change> change password</label></p> |
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
51 <p><input type="submit"></p> |
3 | 52 </form> |
53 <% | |
54 end) | |
54 | 55 else |
55
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
56 local change = Http.request.parameters.change ~= nil |
c57b84f461ae
login and registration work
Franklin Schmidt <fschmidt@gmail.com>
parents:
54
diff
changeset
|
57 local user = User.get_or_create_by_email(email,change) |
6 | 58 local result = call_mail_api( "login_email", { |
59 base_url = base_url() | |
60 from = forum_title.." <support@freedit.org>" | |
61 email = user.email | |
62 password = user.password | |
63 } ) | |
64 result.okay or error(result.error) | |
3 | 65 page(function() |
66 %> | |
54 | 67 <p>We have sent you an email. Please check your email to login.</p> |
3 | 68 <% |
69 end) | |
70 end | |
71 end |