annotate src/unsubscribe.html.luan @ 85:2158a5950fcd

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 11 Mar 2025 14:13:53 -0600
parents e138343b2c76
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Io = require "luan:Io.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Http = require "luan:http/Http.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Shared = require "site:/lib/Shared.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local head = Shared.head or error()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local header = Shared.header or error()
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
8 local User = require "site:/lib/User.luan"
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
9 local Db = require "site:/lib/Db.luan"
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
10 local run_in_transaction = Db.run_in_transaction or error()
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 return function()
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
14 local user_id = Http.request.parameters.user or error()
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
15 local password = Http.request.parameters.password or error()
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
16 run_in_transaction( function()
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
17 local user = User.get_by_id(user_id) or error()
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
18 user.password == password or error()
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
19 user.notify_email = nil
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
20 user.save()
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
21 end )
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 Io.stdout = Http.response.text_writer()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <!doctype html>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 <html>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 <head>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 <% head() %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 </head>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 <body>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 <% header() %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 <div content>
45
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
32 <h1>Unsubscribe</h1>
e138343b2c76 unsubscribe and more
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
33 <p>You have been unsubscribed from notification emails.</p>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 </div>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 </body>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 </html>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 end