-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update 'confirm access' view to not depend on password
Also update the 2FA flows to use 'sudo' mode Update view backup_tokens url and urlname, remove password in it The backup token uses elevate now, and would be possible to confirm access without password
- Loading branch information
Showing
14 changed files
with
340 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 3.2.22 on 2023-10-31 06:59 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0021_pendingsignup"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="ConfirmAccessToken", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("token", models.CharField(max_length=6)), | ||
("created", models.DateTimeField(auto_now_add=True)), | ||
("modified", models.DateTimeField(auto_now=True)), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name_plural": "Confirm Access Tokens", | ||
"ordering": ("modified",), | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
hypha/apply/users/templates/users/emails/confirm_access.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{% load i18n wagtailadmin_tags %}{% base_url_setting as base_url %} | ||
{% blocktrans %}Dear {{ user }},{% endblocktrans %} | ||
|
||
{% blocktrans %}To confirm access at {{ org_long_name }} use the code below (valid for {{ timeout_minutes }} minutes):{% endblocktrans %} | ||
|
||
{{ token }} | ||
|
||
{% blocktrans %}If you did not request this email, please ignore it.{% endblocktrans %} | ||
|
||
{% if org_email %} | ||
{% blocktrans %}If you have any questions, please contact us at {{ org_email }}.{% endblocktrans %} | ||
{% endif %} | ||
|
||
{% blocktrans %}Kind Regards, | ||
The {{ org_short_name }} Team{% endblocktrans %} | ||
|
||
-- | ||
{{ org_long_name }} | ||
{% if site %}{{ site.root_url }}{% else %}{{ base_url }}{% endif %} |
74 changes: 74 additions & 0 deletions
74
hypha/apply/users/templates/users/partials/confirmation_code_sent.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
{% load i18n heroicons %} | ||
<form | ||
class="form form--error-inline px-4 py-4 mb-4 border rounded-sm bg-gray-50 w-full text-center" | ||
id="elevate-check-code-form" | ||
x-data="{ code: '' }" | ||
> | ||
{% csrf_token %} | ||
{% if error %} | ||
<p class="mb-4 font-bold text-red-700">{% trans "Invalid code, please try again!" %}</p> | ||
{% else %} | ||
<p class="mb-4"> | ||
{% heroicon_mini "check-circle" class="inline align-text-bottom fill-green-700" aria_hidden=true %} | ||
<em>{% trans "An email containing a code has been sent. Please check your email for the code." %}</em> | ||
</p> | ||
{% endif %} | ||
|
||
<div class="mb-4"> | ||
<label class="font-bold mr-1" for="id_code">{% trans "Enter Code" %}: </label> | ||
<input | ||
name='code' | ||
id="id_code" | ||
autofocus | ||
required | ||
type='text' | ||
maxlength='6' | ||
class="mb-2 !w-28 placeholder:text-gray-400 text-center tracking-wider" | ||
x-model="code" | ||
autocomplete="off" | ||
placeholder="_ _ _ _ _ _" | ||
data-1p-ignore | ||
> | ||
</div> | ||
|
||
<div> | ||
<button | ||
class="button button-primary block mb-4" | ||
type="submit" | ||
hx-post="{% url 'users:elevate_check_code' %}{% if redirect_url %}?next={{ redirect_url }}{% endif %}" | ||
hx-validate="true" | ||
hx-target="#section-form" | ||
x-bind:disabled="code ? false : true" | ||
> | ||
{% trans "Confirm" %} | ||
</button> | ||
</div> | ||
{% if error %} | ||
<button | ||
class="link hover:underline" | ||
hx-post="{% url 'users:elevate_send_confirm_access_email' %}{% if request.GET.next %}?next={{request.GET.next}}{% endif %}" | ||
hx-target="#section-form" | ||
> | ||
{% trans "Re-send code?" %} | ||
</button> | ||
{% endif %} | ||
</form> | ||
|
||
{% if request.user.has_usable_password %} | ||
<section data-test-id="section-send-email" class="px-4 border pt-2 pb-4"> | ||
<p>{% trans "Having problems?" %}</p> | ||
<ul class="list-disc ml-4"> | ||
<li> | ||
<a | ||
class="m-0" | ||
type="submit" | ||
hx-boost="true" | ||
href="{% url 'users:elevate' %}{% if redirect_url %}?next={{ redirect_url }}{% endif %}" | ||
> | ||
{% trans "Use your password" %} | ||
</a> | ||
</li> | ||
</ul> | ||
</section> | ||
{% endif %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.