Mercurial Hosting > chat
comparison src/do_login.html.luan @ 3:2c63b10781e1
add login
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 24 Oct 2024 21:43:44 -0600 |
| parents | src/index.html.luan@ee1f91e67509 |
| children | a49866b52cc2 |
comparison
equal
deleted
inserted
replaced
| 2:ee1f91e67509 | 3:2c63b10781e1 |
|---|---|
| 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.password or error() | |
| 14 local user = User.get_by_id(user_id) | |
| 15 Io.stdout = Http.response.text_writer() | |
| 16 %> | |
| 17 <!doctype html> | |
| 18 <html> | |
| 19 <head> | |
| 20 <% head() %> | |
| 21 </head> | |
| 22 <body> | |
| 23 <% header() %> | |
| 24 <div content> | |
| 25 <h1>Login / Register</h1> | |
| 26 <% if user == nil or user.password ~= password then %> | |
| 27 <p>Login failed</p> | |
| 28 <% | |
| 29 else | |
| 30 user.login() | |
| 31 %> | |
| 32 <script> location = '/'; </script> | |
| 33 <% | |
| 34 end | |
| 35 %> | |
| 36 </div> | |
| 37 </body> | |
| 38 </html> | |
| 39 <% | |
| 40 end |
