comparison src/relogin.html.luan @ 115:6193996b333d

add relogin
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 27 Nov 2025 20:18:03 -0700
parents
children
comparison
equal deleted inserted replaced
114:d394aad4c3c1 115:6193996b333d
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 Shared = require "site:/lib/Shared.luan"
6 local head = Shared.head or error()
7 local header = Shared.header or error()
8 local User = require "site:/lib/User.luan"
9
10
11 return function()
12 local user_id = Http.request.parameters.user or error()
13 local password = Http.request.parameters.magic or error()
14 local user = User.get_by_id(user_id)
15 local is_good = user ~= nil and user.password == password
16 if is_good then
17 user.login()
18 end
19 Io.stdout = Http.response.text_writer()
20 %>
21 <!doctype html>
22 <html lang="en">
23 <head>
24 <% head() %>
25 </head>
26 <body>
27 <% header() %>
28 <div content>
29 <h1>Re-Login Page</h1>
30 <% if is_good then %>
31 <p>You are logged in.</p>
32 <p>Bookmark this page to login again without dealing with the paranoid security bullshit of modern technology.</p>
33 <%
34 else
35 %>
36 <p>Login failed</p>
37 <%
38 end
39 %>
40 </div>
41 </body>
42 </html>
43 <%
44 end