comparison src/register.html.luan @ 55:c57b84f461ae

login and registration work
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 28 Nov 2022 20:33:47 -0700
parents 260abd8f8565
children
comparison
equal deleted inserted replaced
54:260abd8f8565 55:c57b84f461ae
18 %> 18 %>
19 <!doctype html> 19 <!doctype html>
20 <html> 20 <html>
21 <head> 21 <head>
22 <% head() %> 22 <% head() %>
23 <title><%=forum_title%> - Register or Get Password</title> 23 <title><%=forum_title%> - Register</title>
24 </head> 24 </head>
25 <body> 25 <body>
26 <% header() %> 26 <% header() %>
27 <div content> 27 <div content>
28 <h1>Register or Get Password</h1> 28 <h1>Register</h1>
29 <h3>Or Get or Change Password</h3>
29 <% 30 <%
30 contents() 31 contents()
31 %> 32 %>
32 </div> 33 </div>
33 <% footer() %> 34 <% footer() %>
40 local email = Http.request.parameters.email 41 local email = Http.request.parameters.email
41 if email == nil then 42 if email == nil then
42 page(function() 43 page(function()
43 %> 44 %>
44 <form> 45 <form>
45 <label>Email address</label> 46 <p>
46 <input type="email" name="email" autofocus required> 47 <label>Email address</label>
47 <input type="submit" value="Register or Get Password"> 48 <input type="email" name="email" autofocus required>
49 </p>
50 <p><label clickable><input type=checkbox name=change> change password</label></p>
51 <p><input type="submit"></p>
48 </form> 52 </form>
49 <% 53 <%
50 end) 54 end)
51 else 55 else
52 local user = User.get_or_create_by_email(email) 56 local change = Http.request.parameters.change ~= nil
57 local user = User.get_or_create_by_email(email,change)
53 local result = call_mail_api( "login_email", { 58 local result = call_mail_api( "login_email", {
54 base_url = base_url() 59 base_url = base_url()
55 from = forum_title.." <support@freedit.org>" 60 from = forum_title.." <support@freedit.org>"
56 email = user.email 61 email = user.email
57 password = user.password 62 password = user.password