Mercurial Hosting > chat
diff src/unsubscribe.html.luan @ 45:e138343b2c76
unsubscribe and more
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 28 Feb 2025 14:37:11 -0700 |
parents | src/login_sent.html.luan@2c63b10781e1 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/unsubscribe.html.luan Fri Feb 28 14:37:11 2025 -0700 @@ -0,0 +1,38 @@ +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