Mercurial Hosting > chat
view src/invite.js.luan @ 60:3521166513b3
finish invite
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 04 Mar 2025 20:31:00 -0700 |
parents | 8270106644db |
children | a47036fd0158 |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local Parsers = require "luan:Parsers.luan" local json_string = Parsers.json_string or error() local Http = require "luan:http/Http.luan" local Io = require "luan:Io.luan" local User = require "site:/lib/User.luan" local get_user_by_email = User.get_by_email or error() local get_or_create_user_by_email = User.get_or_create_by_email or error() local current_user = User.current or error() local Shared = require "site:/lib/Shared.luan" local send_mail = Shared.send_mail or error() local Utils = require "site:/lib/Utils.luan" local base_url = Utils.base_url or error() return function() local user = current_user() or error() local email = Http.request.parameters.email or error() Io.stdout = Http.response.text_writer() if get_user_by_email(email) ~= nil then %> location = 'chat?with=<%=email%>'; <% return end local invitee = get_or_create_user_by_email(email) local password = invitee.password local url = base_url().."/do_login.html?user="..invitee.id.."&password="..password.."&with="..user.email local who = user.name or user.email send_mail { To = email Subject = "Chat with "..who body = `%> <%=who%> has invited you to chat on Luan Chat. Here is the link to login: <%= url %> Or login with your email and the password: <%=password%> <% ` } %> openInvite(<%=json_string(email)%>); <% end