Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit af40a16

Browse files
authored
Add snackbar component, notification toasts dont auto hide, add windo… (#112)
* Add snackbar component to show botton page alerts * Show a nudge for users to verify their email address. The alert can be dismissed for the current browser session. * Notification toasts will no longer auto hide * Add `window.init.userVerified` for JavaScript to access the verification state of the user * Requires CTFd/CTFd#2791
1 parent ab1a24b commit af40a16

File tree

4 files changed

+44
-18
lines changed

4 files changed

+44
-18
lines changed

templates/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
'userId': {{ Session.id }},
2525
'userName': {{ User.name | tojson }},
2626
'userEmail': {{ User.email | tojson }},
27+
'userVerified': {{ User.verified | tojson }},
2728
'teamId': {{ Team.id | tojson }},
2829
'teamName': {{ Team.name | tojson }},
2930
'start': {{ Configs.start | tojson }},
@@ -46,6 +47,8 @@
4647
{% endblock %}
4748
</main>
4849

50+
{% include "components/snackbar.html" %}
51+
4952
<footer class="footer">
5053
<div class="container text-center">
5154
<a href="https://ctfd.io" class="text-secondary">

templates/components/notifications.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div x-data>
22
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 11">
3-
<div x-ref="toast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true">
3+
<div x-ref="toast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true" data-bs-autohide="false">
44
<div class="toast-header">
55
<strong class="me-auto" x-text="$store.toast.title"></strong>
66
<small>just now</small>

templates/components/snackbar.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% if can_send_mail() %}
2+
<div
3+
x-data
4+
x-show="window.init.userId && !window.init.userVerified && localStorage.getItem('remind_email_verify') != window.init.userId && (!['/team', '/teams/join', '/teams/new'].includes(window.location.pathname) || window.init.teamId != null)"
5+
class="alert alert-info alert-dismissible col-md-4 col-10 position-fixed text-center m-0"
6+
style="bottom: 45px; left: 50%; transform: translateX(-50%); z-index: 1040; display: none;"
7+
role="alert"
8+
>
9+
<small>
10+
<strong>Email Unconfirmed</strong><br>
11+
<span>To confirm your email address please <a href="{{ url_for('auth.confirm', flow='init') }}">click here</a>.</span>
12+
</small>
13+
<button type="button" class="btn-close" @click="localStorage.setItem('remind_email_verify', window.init.userId); $el.parentElement.style.display = 'none';" aria-label="Close"></button>
14+
</div>
15+
{% endif %}

templates/confirm.html

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,40 @@ <h1>
1414
<div class="col-md-10 col-lg-8 col-xl-6 offset-md-1 offset-lg-2 offset-xl-3">
1515
{% include "components/errors.html" %}
1616

17-
<h5 class="text-center">
18-
{% trans %}We've sent a confirmation email to your email address.{% endtrans %}
19-
</h5>
20-
21-
<br>
22-
23-
<h5 class="text-center">
24-
{% trans %}Please click the link in that email to confirm your account.{% endtrans %}
25-
</h5>
26-
27-
<br>
28-
29-
<h5 class="text-center">
30-
{% trans %}If the email doesn’t arrive, check your spam folder or contact an administrator to manually verify your account.{% endtrans %}
31-
</h5>
17+
{% if request.args.get('flow') == "init" %}
18+
<h5 class="text-center">
19+
{% trans %}To send a confirmation email to your email address, please click the button below.{% endtrans %}
20+
</h5>
21+
<br>
22+
<h5 class="text-center">
23+
{% trans %}Please click the link in that email to confirm your account.{% endtrans %}
24+
</h5>
25+
<h5 class="text-center">
26+
{% trans %}If the email doesn’t arrive, check your spam folder or contact an administrator to manually verify your account.{% endtrans %}
27+
</h5>
28+
{% else%}
29+
<h5 class="text-center">
30+
{% trans %}We've sent a confirmation email to your email address.{% endtrans %}
31+
</h5>
32+
<br>
33+
<h5 class="text-center">
34+
{% trans %}Please click the link in that email to confirm your account.{% endtrans %}
35+
</h5>
36+
<h5 class="text-center">
37+
{% trans %}If the email doesn’t arrive, check your spam folder or contact an administrator to manually verify your account.{% endtrans %}
38+
</h5>
39+
{% endif %}
3240

3341
<hr>
3442

3543
{% with form = Forms.auth.ConfirmForm() %}
3644
<form method="POST" action="{{ url_for('auth.confirm') }}">
3745
<div class="row">
3846
<div class="mb-3 col-md-6">
39-
{{ form.submit(class="btn btn-primary w-100") }}
47+
{{ form.submit(class="btn btn-primary w-100 p-2") }}
4048
</div>
4149
<div class="mb-3 col-md-6">
42-
<a href="{{ url_for('views.settings') }}" class="btn btn-secondary w-100">
50+
<a href="{{ url_for('views.settings') }}" class="btn btn-secondary w-100 p-2">
4351
{% trans %}Change Email Address{% endtrans %}
4452
</a>
4553
</div>

0 commit comments

Comments
 (0)