Mercurial Hosting > freedit
comparison src/login.html.luan @ 4:a17e400ddaa1
add email
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 21 Jun 2022 11:58:27 -0600 |
parents | fc3ee39d7764 |
children | 9166f6a14021 |
comparison
equal
deleted
inserted
replaced
3:fc3ee39d7764 | 4:a17e400ddaa1 |
---|---|
3 local String = require "luan:String.luan" | 3 local String = require "luan:String.luan" |
4 local trim = String.trim or error() | 4 local trim = String.trim or error() |
5 local Html = require "luan:Html.luan" | 5 local Html = require "luan:Html.luan" |
6 local url_encode = Html.url_encode or error() | 6 local url_encode = Html.url_encode or error() |
7 local Io = require "luan:Io.luan" | 7 local Io = require "luan:Io.luan" |
8 local output_of = Io.output_of or error() | |
8 local Http = require "luan:http/Http.luan" | 9 local Http = require "luan:http/Http.luan" |
9 local Shared = require "site:/lib/Shared.luan" | 10 local Shared = require "site:/lib/Shared.luan" |
10 local head = Shared.head or error() | 11 local head = Shared.head or error() |
11 local header = Shared.header or error() | 12 local header = Shared.header or error() |
12 local footer = Shared.footer or error() | 13 local footer = Shared.footer or error() |
13 local base_url = Shared.base_url or error() | 14 local base_url = Shared.base_url or error() |
14 local Forum = require "site:/lib/Forum.luan" | 15 local Forum = require "site:/lib/Forum.luan" |
15 local forum_title = Forum.title or error() | 16 local forum_title = Forum.title or error() |
16 local User = require "site:/lib/User.luan" | 17 local User = require "site:/lib/User.luan" |
18 local Mail = require "site:/lib/Mail.luan" | |
17 local Db = require "site:/lib/Db.luan" | 19 local Db = require "site:/lib/Db.luan" |
18 local run_in_transaction = Db.run_in_transaction or error() | 20 local run_in_transaction = Db.run_in_transaction or error() |
19 | 21 |
20 | 22 |
21 local function get_user(email,password) | 23 local function get_user(email,password) |
83 </form> | 85 </form> |
84 <% | 86 <% |
85 end) | 87 end) |
86 elseif password == nil then | 88 elseif password == nil then |
87 local user = User.get_or_create_by_email(email) | 89 local user = User.get_or_create_by_email(email) |
90 local mailer = Mail.sender() or error "mail not configured" | |
91 mailer.send{ | |
92 From = forum_title.." <support@freedit.org>" | |
93 To = user.email | |
94 Subject = "Login" | |
95 body = output_of(function() %> | |
96 Login or register by clicking this link: | |
97 | |
98 <%=base_url()%>/login.html?email=<%=url_encode(email)%>&password=<%=user.password%> | |
99 <% end) | |
100 } | |
88 page(function() | 101 page(function() |
89 %> | 102 %> |
90 <p>We have sent you an email. Please check your email to login or register.</p> | 103 <p>We have sent you an email. Please check your email to login or register.</p> |
91 <p>hack - <a href="<%=base_url()%>/login.html?email=<%=url_encode(email)%>&password=<%=user.password%>">link</a></p> | |
92 <% | 104 <% |
93 end) | 105 end) |
94 elseif name == nil then | 106 elseif name == nil then |
95 local user = get_user(email,password) | 107 local user = get_user(email,password) |
96 if user.name == nil then | 108 if user.name == nil then |