Skip to content

Commit

Permalink
feat: simple support for OTP register operation
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed May 22, 2024
1 parent 703f08e commit 780c9c8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/appier_extras/parts/admin/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def routes(self):
(("GET",), "/admin/2fa", self.two_factor),
(("GET",), "/admin/otp", self.otp),
(("POST",), "/admin/otp", self.otp_login),
(("GET",), "/admin/otp/register", self.otp_register),
(("GET",), "/admin/fido2", self.fido2),
(("POST",), "/admin/fido2", self.fido2_login),
(("GET",), "/admin/fido2/register", self.fido2_register),
Expand Down Expand Up @@ -742,6 +743,14 @@ def otp_login(self):
# alternative to the root index of the administration
return self.redirect(next or self.url_for(self.owner.admin_login_redirect))

def otp_register(self):
next = self.field("next")

account = self.account_c.from_session()
account.generate_otp_s()

return self.template("otp_register.html.tpl", next=next)

def fido2(self):
next = self.field("next")
error = self.field("error")
Expand Down
4 changes: 4 additions & 0 deletions src/appier_extras/parts/admin/static/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ body.mobile-s .pages > .page.other {
margin: 0px auto 0px auto;
}

.otp-qrcode {
max-width: 200px;
}

.fido2-register {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
{% block buttons %}
{{ super() }}
<ul class="drop-down drop-down-left" data-name="Operations">
<li>
<a href="{{ url_for('admin.otp_register', next = location_f) }}">Register OTP</a>
</li>
<li>
<a href="{{ url_for('admin.fido2_register', next = location_f) }}">Register FIDO2</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends "admin/admin.simple.html.tpl" %}
{% block title %}OTP Register{% endblock %}
{% block body_style %}{{ super() }} {% if background %}background:url({{ background }});{% endif %}{% endblock %}
{% block content %}
<div class="login-panel {% if error %}login-panel-message{% endif %}">
{% if owner.logo_url %}
<img class="login-logo" src="{{ owner.logo_url }}" />
{% else %}
<h1>OTP</h1>
{% endif %}
<h3>Registering OTP</h3>
{% if error %}
<div class="quote error">{{ error }}</div>
{% endif %}
<form>
<input type="hidden" name="next" value="{{ next|default('', True) }}" />
<img class="otp-qrcode" src="{{ url_for('admin.otp_qrcode') }}" />
</form>
</div>
{% endblock %}

0 comments on commit 780c9c8

Please sign in to comment.