view src/login.html.luan @ 117:e2deb5236f26

better login
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 04 Dec 2025 21:43:47 -0700
parents src/manual_login.html.luan@8c3b56bb0c83
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local ipairs = Luan.ipairs or error()
local Io = require "luan:Io.luan"
local Http = require "luan:http/Http.luan"
local Shared = require "site:/lib/Shared.luan"
local head = Shared.head or error()
local header = Shared.header or error()
local hidden_with = Shared.hidden_with or error()
local add_with = Shared.add_with or error()


return function()
	local email = Http.request.parameters.email
	local password = Http.request.parameters.password
	Io.stdout = Http.response.text_writer()
%>
<!doctype html>
<html lang="en">
	<head>
<%		head() %>
		<style>
			input[name=email] {
				width: 300px;
				max-width: 100%;
			}
			[failed] {
				color: red;
			}
		</style>
	</head>
	<body>
<%		header() %>
		<div content>
			<h1>Login</h1>
			<form page onsubmit="ajaxForm('/login.js',this)" action="javascript:">
<%	if Http.request.parameters.spy ~= nil then %>
				<input type=hidden name=spy>
<%	end
				hidden_with() %>
				<p>
					<label prompt>Your email address</label>
					<input type=email name=email required autofocus value="<%= email or "" %>">
				</p>
				<p>
					<label prompt>Password</label>
					<input name=password type=password required value="<%= password or "" %>">
				</p>
				<p>
					<input type=submit>
				</p>
				<p failed></p>
			</form>
			<p><a href="<%= add_with("register.html") %>">Register / Get Password</a></p>
			<p><a href="about.html">About Luan Chat</a></p>
		</div>
	</body>
</html>
<%
end