changeset 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 c7a899252621
files src/get_password.html.luan
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
diff -r a6be8817c05b -r 46f6b69e8b10 src/get_password.html.luan
--- a/src/get_password.html.luan	Thu Jun 02 19:18:12 2022 -0600
+++ b/src/get_password.html.luan	Fri Jun 03 09:57:45 2022 -0600
@@ -13,8 +13,7 @@
 local save_raw_config = Shared.save_raw_config or error()
 
 
-local mail_info = config.mail_info or error "missing config.mail_info"
-local send_mail = Mail.sender(mail_info).send
+local send_mail = config.mail_info and Mail.sender(config.mail_info).send
 
 local function handle(email)
 	local change = Http.request.parameters.change ~= nil
@@ -25,6 +24,9 @@
 		raw_config.users[email] = password
 		save_raw_config(raw_config)
 	end
+	if send_mail == nil then
+		return "missing config.mail_info, your password is: "..password
+	end
 	local function body()
 %>
 Your password is "<%=password%>".