comparison src/get_password.html.luan @ 21:b14073ab9d07

update luan
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 14 Sep 2024 22:17:26 -0600
parents a6e72cd199f1
children
comparison
equal deleted inserted replaced
20:8b4481769cc6 21:b14073ab9d07
1 local Luan = require "luan:Luan.luan" 1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error 2 local error = Luan.error
3 local String = require "luan:String.luan" 3 local String = require "luan:String.luan"
4 local matches = String.matches or error()
5 local Io = require "luan:Io.luan" 4 local Io = require "luan:Io.luan"
6 local output_of = Io.output_of or error() 5 local output_of = Io.output_of or error()
7 local Http = require "luan:http/Http.luan" 6 local Http = require "luan:http/Http.luan"
8 local Mail = require "luan:mail/Mail.luan" 7 local Mail = require "luan:mail/Mail.luan"
9 local Shared = require "site:/lib/Shared.luan" 8 local Shared = require "site:/lib/Shared.luan"
14 local get_raw_config = Shared.get_raw_config or error() 13 local get_raw_config = Shared.get_raw_config or error()
15 local save_raw_config = Shared.save_raw_config or error() 14 local save_raw_config = Shared.save_raw_config or error()
16 15
17 16
18 local send_mail = config.mail_info and Mail.sender(config.mail_info).send 17 local send_mail = config.mail_info and Mail.sender(config.mail_info).send
18 local email_regex = String.regex[[^(\w[-+~.\w]*)@[-\w]+(\\.[-\w]+)*\.[a-zA-Z]+$]]
19 19
20 local function handle(email) 20 local function handle(email)
21 matches( email, [[^(\w[-+~.\w]*)@[-\w]+(\\.[-\w]+)*\.[a-zA-Z]+$]] ) or error "invalid email" 21 email_regex.matches(email) or error "invalid email"
22 local change = Http.request.parameters.change ~= nil 22 local change = Http.request.parameters.change ~= nil
23 local password = config.users[email] 23 local password = config.users[email]
24 if password == nil or change then 24 if password == nil or change then
25 password = new_password() 25 password = new_password()
26 local raw_config = get_raw_config() 26 local raw_config = get_raw_config()