Mercurial Hosting > chat
diff src/register.js.luan @ 117:e2deb5236f26
better login
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 04 Dec 2025 21:43:47 -0700 |
| parents | src/login.js.luan@7b339b1ccd11 |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/register.js.luan Thu Dec 04 21:43:47 2025 -0700 @@ -0,0 +1,32 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" +local Shared = require "site:/lib/Shared.luan" +local send_mail_async = Shared.send_mail_async or error() +local add_with = Shared.add_with or error() +local Utils = require "site:/lib/Utils.luan" +local to_list = Utils.to_list or error() +local User = require "site:/lib/User.luan" + + +return function() + local email = Http.request.parameters.email or error() + local user = User.get_or_create_by_email(email) + local url = add_with( user.login_url() ) + send_mail_async { + To = email + Subject = "Login" + body = `%> +Here is the link to login: + +<%= url %> + +Your password: <%=user.password%> +<% ` + } + Io.stdout = Http.response.text_writer() +%> + location = '/register_sent.html'; +<% +end
