Skip to content

Commit c9ad184

Browse files
committed
feat(passport): add re login at authorize
1 parent 61c948d commit c9ad184

3 files changed

Lines changed: 41 additions & 26 deletions

File tree

rootfs/api/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from .models import User
55

6+
67
class UserAdmin(BaseUserAdmin):
78
add_fieldsets = (
89
(None, {

rootfs/api/static/css/main.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ h1.logo a:before {
5858
border-image: initial;
5959
}
6060

61+
.panel div {
62+
margin-top: 30px
63+
}
64+
6165
.panel .h3 {
6266
margin: 40px 20px 0;
6367
line-height: 1.5;
@@ -71,7 +75,7 @@ h2 {
7175
color: #664986;
7276
}
7377
.panel form {
74-
padding: 40px
78+
padding: 30px
7579
}
7680

7781
form {

rootfs/api/templates/oauth2_provider/authorize.html

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,41 @@
44
<head>
55
<meta charset="UTF-8">
66
<title>Authorize</title>
7+
<script type="text/javascript">
8+
window.onload=function(){
9+
const element = document.getElementById("logout-link")
10+
element.href += encodeURIComponent(window.location.pathname + window.location.search)
11+
}
12+
</script>
713
</head>
8-
<div class="page-wrap gradient-primary">
9-
<div class="container">
10-
<h1 class="logo"><a href="https://www.drycc.cc" title="Drycc">Drycc</a></h1>
11-
<div class="panel">
12-
{% if not error %}
13-
<h2 class="h3">{% trans "Authorize" %} {{ application.name }}?</h2>
14-
{{ updated }}
15-
<form id="authorizationForm" method="post">
16-
{% csrf_token %}
17-
{% for field in form %}
18-
{% if field.is_hidden %}
19-
{{ field }}
20-
{% endif %}
21-
{% endfor %}
22-
{{ form.errors }}
23-
{{ form.non_field_errors }}
24-
<br>
25-
<input type="submit" class="btn btn-primary btn-lg btn-block" name="allow" value="{% trans 'Authorize' %}"/>
26-
</form>
27-
{% else %}
28-
<h2 class="h3">{{ error.error }}</h2>
29-
<p class="tc gray-90 inverted-wrapper">{{ error.description }}</p>
30-
<div class="inverted-wrapper"></div>
31-
{% endif %}
14+
<body>
15+
<div class="page-wrap gradient-primary">
16+
<div class="container">
17+
<h1 class="logo"><a href="https://www.drycc.cc" title="Drycc">Drycc</a></h1>
18+
<div class="panel">
19+
{% if not error %}
20+
<h2 class="h3">{% trans "Authorize" %} {{ application.name }}?</h2>
21+
{{ updated }}
22+
<div>{{ application.name }} wants to access your {{ request.user.username }} account</div>
23+
<form id="authorizationForm" method="post">
24+
{% csrf_token %}
25+
{% for field in form %}
26+
{% if field.is_hidden %}
27+
{{ field }}
28+
{% endif %}
29+
{% endfor %}
30+
{{ form.errors }}
31+
{{ form.non_field_errors }}
32+
<br>
33+
<input type="submit" class="btn btn-primary btn-lg btn-block" name="allow" value="{% trans 'Authorize' %}"/>
34+
</form>
35+
<a id="logout-link" class="panel-footer" href="/user/logout?next=">With another account? &nbsp;<span>Sigin In</span></a>
36+
{% else %}
37+
<h2 class="h3">{{ error.error }}</h2>
38+
<p class="tc gray-90 inverted-wrapper">{{ error.description }}</p>
39+
<div class="inverted-wrapper"></div>
40+
{% endif %}
41+
</div>
3242
</div>
3343
</div>
34-
</div>
44+
</body>

0 commit comments

Comments
 (0)