diff 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 diff
--- a/src/login.html.luan	Thu Dec 04 12:13:01 2025 -0700
+++ b/src/login.html.luan	Thu Dec 04 21:43:47 2025 -0700
@@ -1,20 +1,18 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
 local ipairs = Luan.ipairs or error()
-local Html = require "luan:Html.luan"
-local html_encode = Html.encode 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 Utils = require "site:/lib/Utils.luan"
-local to_list = Utils.to_list or error()
+local hidden_with = Shared.hidden_with or error()
+local add_with = Shared.add_with or error()
 
 
 return function()
-	local with = Http.request.parameters.with
-	with = to_list(with)
+	local email = Http.request.parameters.email
+	local password = Http.request.parameters.password
 	Io.stdout = Http.response.text_writer()
 %>
 <!doctype html>
@@ -26,26 +24,34 @@
 				width: 300px;
 				max-width: 100%;
 			}
+			[failed] {
+				color: red;
+			}
 		</style>
 	</head>
 	<body>
 <%		header() %>
 		<div content>
-			<h1>Login / Register</h1>
-			<p>A link to login will be emailed to you.</p>
+			<h1>Login</h1>
 			<form page onsubmit="ajaxForm('/login.js',this)" action="javascript:">
-<%	for _, email in ipairs(with) do %>
-				<input type=hidden name=with value="<%=html_encode(email)%>">
-<%	end %>
+<%	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>
+					<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="manual_login.html">Password Login</a></p>
+			<p><a href="<%= add_with("register.html") %>">Register / Get Password</a></p>
 			<p><a href="about.html">About Luan Chat</a></p>
 		</div>
 	</body>