source: Klonkt/src/views/pages/account.ejs@ 210a9cb

main
Last change on this file since 210a9cb was 6d882b1, checked in by roboburr <roboburr@…>, 3 months ago

feat(account): email address editable

Profile form gets an email field; POST /account/profile validates format +
uniqueness (no other account with that address) and updates email + session.

Co-Authored-By: Claude <noreply@…>

  • Property mode set to 100644
File size: 14.5 KB
RevLine 
[7bc636b]1<div class="container ax-page">
2
3 <header class="ax-header">
4 <a href="/" class="ax-back" aria-label="Terug naar home">←</a>
5 <div>
6 <h1>Account</h1>
[c80e78b]7 <p class="ax-tagline">Profiel en avatar.</p>
[7bc636b]8 </div>
9 </header>
10
11 <% if (success) { %><div class="ax-flash ax-flash-ok"><%= success %></div><% } %>
12 <% if (error) { %><div class="ax-flash ax-flash-err"><%= error %></div><% } %>
13
[8afbdd6]14 <% if (isViewer) { %>
15 <div class="ax-viewer-note" role="note">
16 <span class="ax-viewer-ico" aria-hidden="true">👁️</span>
17 <div>
18 <strong>Kijker-modus</strong>
19 <span>Dit is een demo-account. Je kunt alles bekijken, maar niets wijzigen — ook geen foto of bio.</span>
20 </div>
21 </div>
22 <% } %>
23
[7bc636b]24 <%# ── PROFILE ────────────────────────────────────────────── %>
25 <section class="ax-card">
26 <div class="ax-card-title">Profiel</div>
27
28 <div class="ax-profile-id">
[8afbdd6]29 <% if (canMutate) { %>
30 <form action="/account/avatar" method="post" enctype="multipart/form-data" class="ax-avatar-form">
31 <label class="ax-avatar-wrap" title="Klik om je foto te wijzigen">
32 <span class="ax-profile-avatar">
33 <% if (account.avatar_url) { %>
34 <img src="<%= account.avatar_url %>" alt="">
35 <% } else { %>
36 <span><%= account.username.charAt(0).toUpperCase() %></span>
37 <% } %>
38 </span>
39 <span class="ax-avatar-edit" aria-hidden="true">
40 <svg viewBox="0 0 24 24" width="15" height="15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
41 </span>
42 <input type="file" name="avatar" accept="image/jpeg,image/png,image/webp,image/gif" onchange="this.form.submit()" hidden>
43 </label>
44 </form>
45 <% } else { %>
46 <span class="ax-profile-avatar ax-profile-avatar-static">
47 <% if (account.avatar_url) { %>
48 <img src="<%= account.avatar_url %>" alt="">
49 <% } else { %>
50 <span><%= account.username.charAt(0).toUpperCase() %></span>
51 <% } %>
52 </span>
53 <% } %>
[7bc636b]54 <div class="ax-profile-meta">
55 <div class="ax-profile-name"><%= account.username %></div>
56 <div class="ax-profile-role"><%= account.role %> · <%= account.email %></div>
57 <% if (account.created_at) { %>
58 <div class="ax-profile-joined">Lid sinds <%= formatDate(account.created_at) %></div>
59 <% } %>
[8afbdd6]60 <% if (account.avatar_url && canMutate) { %>
[6150acb]61 <form action="/account/avatar/remove" method="post" class="ax-avatar-remove">
62 <button type="submit" class="ax-linkbtn">Foto verwijderen</button>
63 </form>
[7bc636b]64 <% } %>
65 </div>
[6150acb]66 </div>
[7bc636b]67
[8afbdd6]68 <% if (canMutate) { %>
69 <form action="/account/profile" method="post" class="ax-form ax-form-bio">
[6d882b1]70 <label class="ax-field">
71 <span>E-mailadres</span>
72 <input type="email" name="email" value="<%= account.email || '' %>" maxlength="254" autocomplete="email" placeholder="jij@email.nl">
73 </label>
[8afbdd6]74 <label class="ax-field">
75 <span>Bio</span>
76 <textarea name="bio" rows="3" maxlength="500" placeholder="Een korte regel over jezelf"><%= account.bio || '' %></textarea>
77 </label>
78 <div class="ax-form-actions">
[6d882b1]79 <button type="submit" class="ax-btn ax-btn-primary">Opslaan</button>
[8afbdd6]80 </div>
81 </form>
82 <% } else { %>
83 <div class="ax-form ax-form-bio">
84 <label class="ax-field">
85 <span>Bio</span>
86 <textarea rows="3" disabled placeholder="Geen bio"><%= account.bio || '' %></textarea>
87 </label>
[7bc636b]88 </div>
[8afbdd6]89 <% } %>
[7bc636b]90 </section>
91
[1be21ba]92 <%# ── SITE (eigenaar mag de naam van z'n site aanpassen) ── %>
93 <% if (typeof editableSite !== 'undefined' && editableSite && canMutate) { %>
94 <section class="ax-card">
95 <div class="ax-card-title">Site</div>
96 <form action="/account/site" method="post" class="ax-form">
97 <label class="ax-field">
98 <span>Site-naam <small>— getoond in de kop van je site</small></span>
99 <input type="text" name="site_title" value="<%= editableSite.title || '' %>" maxlength="200" required>
100 </label>
101 <label class="ax-field">
102 <span>Tagline <small>— korte oneliner (optioneel)</small></span>
103 <input type="text" name="site_tagline" value="<%= editableSite.tagline || '' %>" maxlength="200">
104 </label>
105 <div class="ax-form-actions">
106 <button type="submit" class="ax-btn ax-btn-primary">Site opslaan</button>
107 </div>
108 </form>
109 </section>
110 <% } %>
111
[9e27d64]112 <%# ── WACHTWOORD ────────────────────────────────────────── %>
[8afbdd6]113 <%# In kijker-modus geen wachtwoord-sectie (niets te wijzigen). %>
114 <% if (canMutate) { %>
[9e27d64]115 <% if (hasPassword) { %>
116 <section class="ax-card">
117 <div class="ax-card-title">Wachtwoord wijzigen</div>
118 <form action="/account/password" method="post" class="ax-form">
119 <label class="ax-field">
120 <span>Huidig wachtwoord</span>
121 <input type="password" name="current" required autocomplete="current-password">
122 </label>
123 <div class="ax-row ax-row-2">
124 <label class="ax-field">
125 <span>Nieuw wachtwoord <small>(min 8 tekens)</small></span>
126 <input type="password" name="new_password" required minlength="8" autocomplete="new-password">
127 </label>
128 <label class="ax-field">
129 <span>Bevestig nieuw wachtwoord</span>
130 <input type="password" name="confirm" required minlength="8" autocomplete="new-password">
131 </label>
132 </div>
133 <div class="ax-form-actions">
[6150acb]134 <button type="submit" class="ax-btn ax-btn-primary">Wachtwoord wijzigen</button>
[9e27d64]135 </div>
136 </form>
137 </section>
[247988e]138
139 <% if (typeof googleAvailable !== 'undefined' && googleAvailable) { %>
140 <section class="ax-card">
141 <div class="ax-card-title">Inloggen met Google</div>
142 <% if (typeof googleLinked !== 'undefined' && googleLinked) { %>
143 <p class="ax-tagline" style="margin:0 0 1rem">✓ Je Google-account is gekoppeld — je kunt ook met Google inloggen.</p>
144 <form action="/account/google/unlink" method="post">
145 <button type="submit" class="ax-btn">Google ontkoppelen</button>
146 </form>
147 <% } else { %>
148 <p class="ax-tagline" style="margin:0 0 1rem">Koppel je Google-account zodat je voortaan ook met één klik via Google kunt inloggen (naast je wachtwoord).</p>
149 <a href="/auth/google/link" class="ax-btn ax-btn-primary" data-full-load>Koppel Google-account</a>
150 <% } %>
151 </section>
152 <% } %>
[9e27d64]153 <% } else { %>
[7bc636b]154 <section class="ax-card">
[c80e78b]155 <div class="ax-card-title">Inloggen</div>
156 <p class="ax-tagline" style="margin:0">Je bent ingelogd via Google (<%= account.email %>). Er is geen apart wachtwoord.</p>
[7bc636b]157 </section>
[9e27d64]158 <% } %>
[8afbdd6]159 <% } %>
[7bc636b]160
161</div>
162
163<style>
164.ax-page { max-width: 720px; margin: 1.5rem auto 4rem; padding: 0 1rem; }
165.ax-header { display: flex; align-items: flex-start; gap: 0.75rem; margin-bottom: 1.5rem; }
166.ax-header h1 { font-family: var(--font-display, serif); font-size: 1.75rem; margin: 0 0 0.25rem; }
167.ax-tagline { color: var(--ink-muted, var(--ink-soft)); margin: 0; font-size: 0.9rem; }
168.ax-back {
169 display: inline-flex; align-items: center; justify-content: center;
170 width: 40px; height: 40px;
171 border: 1px solid var(--rule); border-radius: 8px;
172 background: var(--paper); color: var(--ink); text-decoration: none;
173 font-size: 1.1rem; flex-shrink: 0; transition: border-color 120ms;
174}
175.ax-back:hover { border-color: var(--accent); }
176
177.ax-flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
178.ax-flash-ok { background: rgba(40,160,90,.15); color: #2a9d5e; border: 1px solid rgba(40,160,90,.3); }
179.ax-flash-err { background: rgba(200,60,60,.15); color: #c33; border: 1px solid rgba(200,60,60,.3); }
180
[8afbdd6]181/* ─── Kijker-modus notice ──────────────────────────────────────── */
182.ax-viewer-note {
183 display: flex; align-items: flex-start; gap: 0.75rem;
184 padding: 0.85rem 1rem; margin-bottom: 1rem;
185 border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--rule));
186 border-left: 3px solid var(--accent);
187 border-radius: 10px;
188 background: color-mix(in srgb, var(--accent) 8%, var(--paper));
189}
190.ax-viewer-ico { font-size: 1.1rem; line-height: 1.4; }
191.ax-viewer-note strong { display: block; font-size: 0.92rem; }
192.ax-viewer-note span { color: var(--ink-muted, var(--ink-soft)); font-size: 0.85rem; }
193.ax-profile-avatar-static { flex-shrink: 0; }
194.ax-form-bio textarea:disabled { opacity: 0.7; cursor: default; }
195
[7bc636b]196/* ─── Cards ────────────────────────────────────────────────────── */
197.ax-card {
198 background: var(--paper);
199 border: 1px solid var(--rule);
200 border-radius: 12px;
201 padding: 1.25rem;
202 margin-bottom: 1rem;
203}
204.ax-card-title {
205 font-family: var(--font-display, serif);
206 font-size: 1.15rem;
207 font-weight: 600;
208 margin-bottom: 1rem;
209}
210
211/* ─── Form fields ──────────────────────────────────────────────── */
212.ax-form { display: flex; flex-direction: column; gap: 0.85rem; }
213.ax-form-bio { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--rule); }
214.ax-row { display: grid; gap: 0.85rem; }
215.ax-row-2 { grid-template-columns: 1fr 1fr; }
216@media (max-width: 600px) { .ax-row-2 { grid-template-columns: 1fr; } }
217
218.ax-field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
219.ax-field > span {
220 font-size: 0.8rem; font-weight: 600;
221 color: var(--ink-soft);
222 display: flex; align-items: baseline; gap: 0.4rem; flex-wrap: wrap;
223}
224.ax-field > span small { font-weight: 400; color: var(--ink-muted); font-size: 0.95em; }
225.ax-field input[type="text"],
226.ax-field input[type="email"],
227.ax-field input[type="password"],
228.ax-field input[type="url"],
229.ax-field select,
230.ax-field textarea {
231 width: 100%;
232 box-sizing: border-box;
233 padding: 0.6rem 0.75rem;
234 border: 1px solid var(--rule);
235 border-radius: 6px;
236 background: var(--paper-2);
237 color: var(--ink);
238 font-family: var(--font-ui, system-ui), sans-serif;
239 font-size: 0.95rem;
240 -webkit-appearance: none; appearance: none;
241 transition: border-color 120ms;
242}
243.ax-field textarea { resize: vertical; min-height: 70px; font-family: inherit; }
244.ax-field input:focus, .ax-field select:focus, .ax-field textarea:focus {
245 outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
246}
247
248/* ─── File upload ─────────────────────────────────────────────── */
249.ax-file-control {
250 display: flex; align-items: center; gap: 0.5rem;
251 flex-wrap: wrap;
252 position: relative;
253 min-height: 40px;
254}
255.ax-file-control input[type="file"] {
256 position: absolute; inset: 0;
257 opacity: 0; cursor: pointer;
258 z-index: 2;
259}
260.ax-file-btn { pointer-events: none; }
261.ax-file-name {
262 font-size: 0.85rem;
263 color: var(--ink);
264 word-break: break-all;
265 flex: 1; min-width: 0;
266}
267.ax-file-name[data-empty] { color: var(--ink-muted, var(--ink-soft)); }
268
269.ax-form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.25rem; }
270
271/* ─── Buttons ──────────────────────────────────────────────────── */
272.ax-btn {
273 display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
274 padding: 0.55rem 1rem;
275 border: 1px solid var(--rule); background: var(--paper-2);
276 color: var(--ink);
277 font-family: var(--font-ui, system-ui), sans-serif;
278 font-size: 0.9rem; font-weight: 500;
279 text-decoration: none; border-radius: 6px;
280 cursor: pointer; min-height: 40px;
281 transition: background 120ms, border-color 120ms;
282 -webkit-tap-highlight-color: transparent;
283}
284.ax-btn:hover { border-color: var(--accent); }
285.ax-btn-secondary { background: var(--paper-2); }
[6fcd0cf]286.ax-btn-primary, a.ax-btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
287.ax-btn-primary:hover, a.ax-btn-primary:hover { opacity: 0.92; border-color: var(--accent); color: #fff; }
[7bc636b]288
289/* ─── Profile ID row ──────────────────────────────────────────── */
290.ax-profile-id {
291 display: flex; align-items: center; gap: 1rem;
292 padding-bottom: 1rem;
293 border-bottom: 1px solid var(--rule);
294 margin-bottom: 1rem;
295}
[6150acb]296.ax-avatar-form { margin: 0; flex-shrink: 0; }
297.ax-avatar-wrap {
298 position: relative; display: block;
299 width: 84px; height: 84px; cursor: pointer;
300}
[7bc636b]301.ax-profile-avatar {
[6150acb]302 width: 84px; height: 84px;
[7bc636b]303 border-radius: 50%;
304 overflow: hidden;
305 background: var(--paper-2); /* neutral so transparent avatars blend */
306 color: var(--accent); /* accent only for the fallback initial */
307 display: inline-flex; align-items: center; justify-content: center;
308 font-family: var(--font-display, serif);
[6150acb]309 font-size: 1.7rem; font-weight: 600;
310 border: 1px solid var(--rule);
311 transition: border-color 120ms;
[7bc636b]312}
[6150acb]313.ax-avatar-wrap:hover .ax-profile-avatar { border-color: var(--accent); }
[7bc636b]314.ax-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
[6150acb]315.ax-avatar-edit {
316 position: absolute; right: -2px; bottom: -2px;
317 width: 28px; height: 28px; border-radius: 50%;
318 background: var(--accent); color: #fff;
319 display: flex; align-items: center; justify-content: center;
320 border: 3px solid var(--paper);
321 transition: transform 120ms;
322}
323.ax-avatar-wrap:hover .ax-avatar-edit { transform: scale(1.08); }
324.ax-avatar-remove { margin-top: 0.45rem; }
325.ax-linkbtn {
326 background: none; border: 0; padding: 0; cursor: pointer;
327 color: var(--ink-muted, var(--ink-soft)); font-size: 0.8rem; text-decoration: underline;
328 font-family: var(--font-ui, system-ui), sans-serif;
329}
330.ax-linkbtn:hover { color: #c33; }
[7bc636b]331.ax-profile-meta { min-width: 0; }
332.ax-profile-name { font-weight: 600; font-size: 1.1rem; }
333.ax-profile-role,
334.ax-profile-joined {
335 color: var(--ink-muted, var(--ink-soft));
336 font-size: 0.85rem;
337}
338
339@media (max-width: 480px) {
340 .ax-profile-id { flex-direction: column; align-items: flex-start; gap: 0.75rem; text-align: left; }
341}
342</style>
Note: See TracBrowser for help on using the repository browser.