Mercurial Hosting > freedit
diff 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 |
line wrap: on
line diff
--- a/src/login.html.luan Tue Jun 21 21:39:27 2022 -0600 +++ b/src/login.html.luan Thu Jun 23 23:05:28 2022 -0600 @@ -12,10 +12,10 @@ local header = Shared.header or error() local footer = Shared.footer or error() local base_url = Shared.base_url or error() +local call_mail_api = Shared.call_mail_api or error() local Forum = require "site:/lib/Forum.luan" local forum_title = Forum.title or error() local User = require "site:/lib/User.luan" -local Mail = require "site:/lib/Mail.luan" local Db = require "site:/lib/Db.luan" local run_in_transaction = Db.run_in_transaction or error() @@ -87,17 +87,13 @@ end) elseif password == nil then local user = User.get_or_create_by_email(email) - local mailer = Mail.sender() or error "mail not configured" - mailer.send{ - From = forum_title.." <support@freedit.org>" - To = user.email - Subject = "Login" - body = output_of(function() %> -Login or register by clicking this link: - -<%=base_url()%>/login.html?email=<%=url_encode(email)%>&password=<%=user.password%> -<% end) - } + local result = call_mail_api( "login_email", { + base_url = base_url() + from = forum_title.." <support@freedit.org>" + email = user.email + password = user.password + } ) + result.okay or error(result.error) page(function() %> <p>We have sent you an email. Please check your email to login or register.</p>