comparison src/login.js.luan @ 88:7b339b1ccd11

add tools/users.html
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 13 Mar 2025 16:18:39 -0600
parents a47036fd0158
children
comparison
equal deleted inserted replaced
87:246a792adedf 88:7b339b1ccd11
6 local Io = require "luan:Io.luan" 6 local Io = require "luan:Io.luan"
7 local Http = require "luan:http/Http.luan" 7 local Http = require "luan:http/Http.luan"
8 local Shared = require "site:/lib/Shared.luan" 8 local Shared = require "site:/lib/Shared.luan"
9 local send_mail_async = Shared.send_mail_async or error() 9 local send_mail_async = Shared.send_mail_async or error()
10 local Utils = require "site:/lib/Utils.luan" 10 local Utils = require "site:/lib/Utils.luan"
11 local base_url = Utils.base_url or error()
12 local to_list = Utils.to_list or error() 11 local to_list = Utils.to_list or error()
13 local User = require "site:/lib/User.luan" 12 local User = require "site:/lib/User.luan"
14 13
15 14
16 return function() 15 return function()
17 local email = Http.request.parameters.email or error() 16 local email = Http.request.parameters.email or error()
18 local user = User.get_or_create_by_email(email) 17 local user = User.get_or_create_by_email(email)
19 local password = user.password 18 local url = user.login_url()
20 local url = base_url().."/do_login.html?user="..user.id.."&password="..password
21 local with = Http.request.parameters.with 19 local with = Http.request.parameters.with
22 with = to_list(with) 20 with = to_list(with)
23 for _, email in ipairs(with) do 21 for _, email in ipairs(with) do
24 url = url.."&with="..url_encode(email) 22 url = url.."&with="..url_encode(email)
25 end 23 end
29 body = `%> 27 body = `%>
30 Here is the link to login: 28 Here is the link to login:
31 29
32 <%= url %> 30 <%= url %>
33 31
34 Or login with your email and the password: <%=password%> 32 Or login with your email and the password: <%=user.password%>
35 <% ` 33 <% `
36 } 34 }
37 Io.stdout = Http.response.text_writer() 35 Io.stdout = Http.response.text_writer()
38 %> 36 %>
39 location = '/login_sent.html'; 37 location = '/login_sent.html';