Mercurial Hosting > hghosting
comparison src/get_password.html.luan @ 7:46f6b69e8b10
better handling of missing mail_info
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Fri, 03 Jun 2022 09:57:45 -0600 |
| parents | a6be8817c05b |
| children | a6e72cd199f1 |
comparison
equal
deleted
inserted
replaced
| 6:a6be8817c05b | 7:46f6b69e8b10 |
|---|---|
| 11 local new_password = Shared.new_password or error() | 11 local new_password = Shared.new_password or error() |
| 12 local get_raw_config = Shared.get_raw_config or error() | 12 local get_raw_config = Shared.get_raw_config or error() |
| 13 local save_raw_config = Shared.save_raw_config or error() | 13 local save_raw_config = Shared.save_raw_config or error() |
| 14 | 14 |
| 15 | 15 |
| 16 local mail_info = config.mail_info or error "missing config.mail_info" | 16 local send_mail = config.mail_info and Mail.sender(config.mail_info).send |
| 17 local send_mail = Mail.sender(mail_info).send | |
| 18 | 17 |
| 19 local function handle(email) | 18 local function handle(email) |
| 20 local change = Http.request.parameters.change ~= nil | 19 local change = Http.request.parameters.change ~= nil |
| 21 local password = config.users[email] | 20 local password = config.users[email] |
| 22 if password == nil or change then | 21 if password == nil or change then |
| 23 password = new_password() | 22 password = new_password() |
| 24 local raw_config = get_raw_config() | 23 local raw_config = get_raw_config() |
| 25 raw_config.users[email] = password | 24 raw_config.users[email] = password |
| 26 save_raw_config(raw_config) | 25 save_raw_config(raw_config) |
| 26 end | |
| 27 if send_mail == nil then | |
| 28 return "missing config.mail_info, your password is: "..password | |
| 27 end | 29 end |
| 28 local function body() | 30 local function body() |
| 29 %> | 31 %> |
| 30 Your password is "<%=password%>". | 32 Your password is "<%=password%>". |
| 31 <% | 33 <% |
