view src/unsubscribe.html.luan @ 54:1d724f187cff

minor fix
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 03 Mar 2025 21:19:12 -0700
parents e138343b2c76
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.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 User = require "site:/lib/User.luan"
local Db = require "site:/lib/Db.luan"
local run_in_transaction = Db.run_in_transaction or error()


return function()
	local user_id = Http.request.parameters.user or error()
	local password = Http.request.parameters.password or error()
	run_in_transaction( function()
		local user = User.get_by_id(user_id) or error()
		user.password == password or error()
		user.notify_email = nil
		user.save()
	end )
	Io.stdout = Http.response.text_writer()
%>
<!doctype html>
<html>
	<head>
<%		head() %>
	</head>
	<body>
<%		header() %>
		<div content>
			<h1>Unsubscribe</h1>
			<p>You have been unsubscribed from notification emails.</p>
		</div>
	</body>
</html>
<%
end