Mercurial Hosting > chat
comparison 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 | 8c3b56bb0c83 |
comparison
equal
deleted
inserted
replaced
| 44:1aa50739475a | 45:e138343b2c76 |
|---|---|
| 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 local Db = require "site:/lib/Db.luan" | |
| 10 local run_in_transaction = Db.run_in_transaction or error() | |
| 11 | |
| 12 | |
| 13 return function() | |
| 14 local user_id = Http.request.parameters.user or error() | |
| 15 local password = Http.request.parameters.password or error() | |
| 16 run_in_transaction( function() | |
| 17 local user = User.get_by_id(user_id) or error() | |
| 18 user.password == password or error() | |
| 19 user.notify_email = nil | |
| 20 user.save() | |
| 21 end ) | |
| 22 Io.stdout = Http.response.text_writer() | |
| 23 %> | |
| 24 <!doctype html> | |
| 25 <html> | |
| 26 <head> | |
| 27 <% head() %> | |
| 28 </head> | |
| 29 <body> | |
| 30 <% header() %> | |
| 31 <div content> | |
| 32 <h1>Unsubscribe</h1> | |
| 33 <p>You have been unsubscribed from notification emails.</p> | |
| 34 </div> | |
| 35 </body> | |
| 36 </html> | |
| 37 <% | |
| 38 end |
