comparison src/invite.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
10 local get_user_by_email = User.get_by_email or error() 10 local get_user_by_email = User.get_by_email or error()
11 local get_or_create_user_by_email = User.get_or_create_by_email or error() 11 local get_or_create_user_by_email = User.get_or_create_by_email or error()
12 local current_user = User.current or error() 12 local current_user = User.current or error()
13 local Shared = require "site:/lib/Shared.luan" 13 local Shared = require "site:/lib/Shared.luan"
14 local send_mail = Shared.send_mail or error() 14 local send_mail = Shared.send_mail or error()
15 local Utils = require "site:/lib/Utils.luan"
16 local base_url = Utils.base_url or error()
17 15
18 16
19 return function() 17 return function()
20 local user = current_user() or error() 18 local user = current_user() or error()
21 local email = Http.request.parameters.email or error() 19 local email = Http.request.parameters.email or error()
25 location = 'chat?with=<%=url_encode(email)%>'; 23 location = 'chat?with=<%=url_encode(email)%>';
26 <% 24 <%
27 return 25 return
28 end 26 end
29 local invitee = get_or_create_user_by_email(email) 27 local invitee = get_or_create_user_by_email(email)
30 local password = invitee.password 28 local url = invitee.login_url().."&with="..url_encode(user.email)
31 local url = base_url().."/do_login.html?user="..invitee.id.."&password="..password.."&with="..url_encode(user.email)
32 local who = user.name or user.email 29 local who = user.name or user.email
33 send_mail { 30 send_mail {
34 To = email 31 To = email
35 Subject = "Chat with "..who 32 Subject = "Chat with "..who
36 body = `%> 33 body = `%>
38 35
39 Here is the link to login: 36 Here is the link to login:
40 37
41 <%= url %> 38 <%= url %>
42 39
43 Or login with your email and the password: <%=password%> 40 Or login with your email and the password: <%=invitee.password%>
44 <% ` 41 <% `
45 } 42 }
46 %> 43 %>
47 openInvite(<%=json_string(email)%>); 44 openInvite(<%=json_string(email)%>);
48 <% 45 <%