Mercurial Hosting > linkmystyle
comparison src/forgot.js.luan @ 0:8f4df159f06b
start public repo
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 11 Jul 2025 20:57:49 -0600 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8f4df159f06b |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local Io = require "luan:Io.luan" | |
4 local Http = require "luan:http/Http.luan" | |
5 local User = require "site:/lib/User.luan" | |
6 local Shared = require "site:/lib/Shared.luan" | |
7 local js_error = Shared.js_error or error() | |
8 local send_mail_async = Shared.send_mail_async or error() | |
9 | |
10 | |
11 return function() | |
12 local email = Http.request.parameters.email or error() | |
13 local user = User.get_by_email(email) | |
14 Io.stdout = Http.response.text_writer() | |
15 if user == nil or user.registered == nil then | |
16 js_error( "email", "Email not found" ) | |
17 return | |
18 end | |
19 send_mail_async { | |
20 From = "Link My Style <support@linkmy.style>" | |
21 To = email | |
22 Subject = "Account information" | |
23 body = `%> | |
24 Here is your account information: | |
25 username: <%=user.name%> | |
26 password: <%=user.password%> | |
27 <%` | |
28 } | |
29 %> | |
30 clearErrors(context.form); | |
31 location = '/forgot2.html?email=<%=email%>'; | |
32 <% | |
33 end |