Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5e0a765a
authored
Aug 10, 2016
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: nicer 2fa login page
parent
b83e5628
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
15 deletions
+37
-15
circle/dashboard/forms.py
+2
-3
circle/dashboard/static/dashboard/dashboard.less
+14
-0
circle/dashboard/views/user.py
+10
-4
circle/templates/registration/two-factor-login.html
+11
-8
No files found.
circle/dashboard/forms.py
View file @
5e0a765a
...
@@ -1670,9 +1670,8 @@ class TwoFactorForm(ModelForm):
...
@@ -1670,9 +1670,8 @@ class TwoFactorForm(ModelForm):
class
TwoFactorConfirmationForm
(
forms
.
Form
):
class
TwoFactorConfirmationForm
(
forms
.
Form
):
confirmation_code
=
forms
.
CharField
(
confirmation_code
=
forms
.
CharField
(
label
=
_
(
'Confirmation code'
),
label
=
_
(
'Two-factor authentication passcode'
),
help_text
=
_
(
"Get the code from your authenticator to disable "
help_text
=
_
(
"Get the code from your authenticator."
))
"two-factor authentication."
))
def
__init__
(
self
,
user
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
user
,
*
args
,
**
kwargs
):
self
.
user
=
user
self
.
user
=
user
...
...
circle/dashboard/static/dashboard/dashboard.less
View file @
5e0a765a
...
@@ -1549,3 +1549,17 @@ textarea[name="new_members"] {
...
@@ -1549,3 +1549,17 @@ textarea[name="new_members"] {
margin-left: 15px;
margin-left: 15px;
}
}
}
}
#two-factor-box {
.help-block {
display: block;
}
h4 {
margin: 0;
}
hr {
margin: 15px 0 2px 0;
}
}
circle/dashboard/views/user.py
View file @
5e0a765a
...
@@ -622,15 +622,21 @@ class TwoFactorLoginView(FormView):
...
@@ -622,15 +622,21 @@ class TwoFactorLoginView(FormView):
return
super
(
TwoFactorLoginView
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
return
super
(
TwoFactorLoginView
,
self
)
.
dispatch
(
*
args
,
**
kwargs
)
def
get_user
(
self
):
return
User
.
objects
.
get
(
pk
=
self
.
request
.
session
[
'two-fa-user'
])
def
get_form_kwargs
(
self
):
def
get_form_kwargs
(
self
):
kwargs
=
super
(
TwoFactorLoginView
,
self
)
.
get_form_kwargs
()
kwargs
=
super
(
TwoFactorLoginView
,
self
)
.
get_form_kwargs
()
user_pk
=
self
.
request
.
session
[
'two-fa-user'
]
kwargs
[
'user'
]
=
self
.
get_user
()
kwargs
[
'user'
]
=
User
.
objects
.
get
(
pk
=
user_pk
)
return
kwargs
return
kwargs
def
get_context_data
(
self
,
**
kwargs
):
ctx
=
super
(
TwoFactorLoginView
,
self
)
.
get_context_data
(
**
kwargs
)
ctx
[
'user'
]
=
self
.
get_user
()
return
ctx
def
form_valid
(
self
,
form
):
def
form_valid
(
self
,
form
):
user_pk
=
self
.
request
.
session
[
'two-fa-user'
]
user
=
self
.
get_user
()
user
=
User
.
objects
.
get
(
pk
=
user_pk
)
if
self
.
request
.
session
[
'login-type'
]
==
"saml2"
:
if
self
.
request
.
session
[
'login-type'
]
==
"saml2"
:
user
.
backend
=
'common.backends.Saml2Backend'
user
.
backend
=
'common.backends.Saml2Backend'
...
...
circle/templates/registration/two-factor-login.html
View file @
5e0a765a
...
@@ -4,21 +4,24 @@
...
@@ -4,21 +4,24 @@
{% load crispy_forms_tags %}
{% load crispy_forms_tags %}
{% get_current_language as LANGUAGE_CODE %}
{% get_current_language as LANGUAGE_CODE %}
{% block title-page %}{% trans "
Logi
n" %}{% endblock %}
{% block title-page %}{% trans "
Two-factor authenticatio
n" %}{% endblock %}
{% block content_box %}
{% block content_box %}
<div
class=
"row"
>
<div
class=
"row"
id=
"two-factor-box"
>
<div
class=
"col-md-12"
>
<div
class=
"col-md-12"
>
<h4>
{% blocktrans with username=user.username full_name=user.get_full_name %}
Welcome {{ full_name }} ({{ username }})!
{% endblocktrans %}
</h4>
<hr/>
<form
action=
""
method=
"POST"
>
<form
action=
""
method=
"POST"
>
{% csrf_token %}
{% csrf_token %}
{{ form.confirmation_code|as_crispy_field }}
{{ form.confirmation_code|as_crispy_field }}
<input
type=
"submit"
/>
<button
type=
"submit"
class=
"btn btn-success"
>
{% trans "Confirm" %}
</button>
</form>
</form>
</div>
</div>
</div>
</div>
<style>
.help-block
{
display
:
block
;
}
</style>
{% endblock %}
{% endblock %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment