0
|
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()
|
5
|
8 local Utils = require "site:/lib/Utils.luan"
|
|
9 local base_url = Utils.base_url or error()
|
|
10 local User = require "site:/lib/User.luan"
|
|
11 local current_user = User.current_required or error()
|
0
|
12
|
|
13
|
|
14 return function()
|
5
|
15 local user = current_user()
|
|
16 if user == nil then return end
|
0
|
17 Io.stdout = Http.response.text_writer()
|
|
18 %>
|
|
19 <!doctype html>
|
|
20 <html>
|
|
21 <head>
|
|
22 <% head() %>
|
20
|
23 <script>
|
|
24 'use strict';
|
|
25
|
|
26 function deleteUser() {
|
|
27 let dialog = document.querySelector('dialog[delete_user]');
|
|
28 openModal(dialog);
|
|
29 }
|
|
30
|
|
31 function doDeleteUser(el) {
|
|
32 closeModal(el);
|
|
33 ajax('delete_user.js');
|
|
34 }
|
|
35 </script>
|
34
|
36 <style>
|
|
37 div[content] {
|
|
38 margin-left: auto;
|
|
39 margin-right: auto;
|
|
40 width: fit-content;
|
|
41 }
|
|
42 h1 {
|
|
43 text-align: center;
|
|
44 }
|
|
45 </style>
|
0
|
46 </head>
|
|
47 <body>
|
|
48 <% header() %>
|
|
49 <div content>
|
3
|
50 <h1>Your Account</h1>
|
21
|
51 <p><a href="about.html">About Web Chat</a></p>
|
|
52 <p>Your URL: <%= base_url() %>/?with=<%=user.email%></p>
|
34
|
53 <p><a href="javascript:logout()">Logout</a></p>
|
20
|
54 <p><a href="javascript:deleteUser()">Delete account</a></p>
|
0
|
55 </div>
|
20
|
56 <dialog delete_user>
|
|
57 <h2>Delete Account</h2>
|
|
58 <p>Are you sure that you want to delete your account?</p>
|
|
59 <div buttons>
|
|
60 <button cancel onclick="closeModal(this)">Cancel</button>
|
|
61 <button go onclick="doDeleteUser(this)">Delete</button>
|
|
62 </div>
|
|
63 </dialog>
|
0
|
64 </body>
|
|
65 </html>
|
|
66 <%
|
|
67 end
|