Mercurial Hosting > freedit
comparison src/login.html.luan @ 6:9166f6a14021
add email api
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 23 Jun 2022 23:05:28 -0600 |
parents | a17e400ddaa1 |
children | 7d0c96408abf |
comparison
equal
deleted
inserted
replaced
5:2f20b11affdd | 6:9166f6a14021 |
---|---|
10 local Shared = require "site:/lib/Shared.luan" | 10 local Shared = require "site:/lib/Shared.luan" |
11 local head = Shared.head or error() | 11 local head = Shared.head or error() |
12 local header = Shared.header or error() | 12 local header = Shared.header or error() |
13 local footer = Shared.footer or error() | 13 local footer = Shared.footer or error() |
14 local base_url = Shared.base_url or error() | 14 local base_url = Shared.base_url or error() |
15 local call_mail_api = Shared.call_mail_api or error() | |
15 local Forum = require "site:/lib/Forum.luan" | 16 local Forum = require "site:/lib/Forum.luan" |
16 local forum_title = Forum.title or error() | 17 local forum_title = Forum.title or error() |
17 local User = require "site:/lib/User.luan" | 18 local User = require "site:/lib/User.luan" |
18 local Mail = require "site:/lib/Mail.luan" | |
19 local Db = require "site:/lib/Db.luan" | 19 local Db = require "site:/lib/Db.luan" |
20 local run_in_transaction = Db.run_in_transaction or error() | 20 local run_in_transaction = Db.run_in_transaction or error() |
21 | 21 |
22 | 22 |
23 local function get_user(email,password) | 23 local function get_user(email,password) |
85 </form> | 85 </form> |
86 <% | 86 <% |
87 end) | 87 end) |
88 elseif password == nil then | 88 elseif password == nil then |
89 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" | 90 local result = call_mail_api( "login_email", { |
91 mailer.send{ | 91 base_url = base_url() |
92 From = forum_title.." <support@freedit.org>" | 92 from = forum_title.." <support@freedit.org>" |
93 To = user.email | 93 email = user.email |
94 Subject = "Login" | 94 password = user.password |
95 body = output_of(function() %> | 95 } ) |
96 Login or register by clicking this link: | 96 result.okay or error(result.error) |
97 | |
98 <%=base_url()%>/login.html?email=<%=url_encode(email)%>&password=<%=user.password%> | |
99 <% end) | |
100 } | |
101 page(function() | 97 page(function() |
102 %> | 98 %> |
103 <p>We have sent you an email. Please check your email to login or register.</p> | 99 <p>We have sent you an email. Please check your email to login or register.</p> |
104 <% | 100 <% |
105 end) | 101 end) |