annotate src/api/login_email.json.luan @ 57:169ac5fdb320

add change email
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 28 Nov 2022 23:47:19 -0700
parents 260abd8f8565
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Html = require "luan:Html.luan"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local url_encode = Html.url_encode or error()
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Io = require "luan:Io.luan"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local output_of = Io.output_of or error()
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Http = require "luan:http/Http.luan"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Mail = require "site:/lib/Mail.luan"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Api = require "site:/api/Api.luan"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local api = Api.api or error()
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local user_error = Api.user_error or error()
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 return api(function()
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 local base_url = Http.request.parameters.base_url or user_error "missing base_url param"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 local from = Http.request.parameters.from or user_error "missing from param"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 local email = Http.request.parameters.email or user_error "missing email param"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 local password = Http.request.parameters.password or user_error "missing password param"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 local mailer = Mail.sender() or user_error "mail not configured"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 mailer.send{
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 From = from
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 To = email
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 Subject = "Login"
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 body = output_of(function() %>
54
260abd8f8565 login and register
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
25 Your password is: <%=password%>
260abd8f8565 login and register
Franklin Schmidt <fschmidt@gmail.com>
parents: 6
diff changeset
26
6
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 Login or register by clicking this link:
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 <%=base_url%>/login.html?email=<%=url_encode(email)%>&password=<%=password%>
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 <% end)
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 }
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 return {
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 okay = true
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 }
9166f6a14021 add email api
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 end)