source: Klonkt/src/views/pages/account.ejs@ 3ca24f9

main
Last change on this file since 3ca24f9 was 247988e, checked in by roboburr <roboburr@…>, 3 months ago

feat(auth): admin can link Google and use it to log in

  • Account → "Sign in with Google": link/unlink your Google account (/auth/google/link, requireAuth → stores google_sub on own account).
  • Google callback: link mode alongside login mode. An admin may log in with Google ONLY if their google_sub is linked and matches (otherwise "Google = never admin" rule holds). Unlinking requires a password (no lockout).
  • Admin notice on the login page explains the link route.

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

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