SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
33a77c6f
Commit
33a77c6f
authored
5 years ago
by
Jean-Sébastien Caux
Browse files
Options
Downloads
Patches
Plain Diff
Add TOTPDevice to admin
parent
39dc7b26
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
scipost/admin.py
+14
-1
14 additions, 1 deletion
scipost/admin.py
scipost/migrations/0027_auto_20190826_0924.py
+17
-0
17 additions, 0 deletions
scipost/migrations/0027_auto_20190826_0924.py
scipost/models.py
+1
-0
1 addition, 0 deletions
scipost/models.py
scipost/totp.py
+4
-4
4 additions, 4 deletions
scipost/totp.py
with
36 additions
and
5 deletions
scipost/admin.py
+
14
−
1
View file @
33a77c6f
...
...
@@ -8,7 +8,7 @@ from django import forms
from
django.contrib.auth.admin
import
UserAdmin
from
django.contrib.auth.models
import
User
,
Permission
from
scipost.models
import
Contributor
,
Remark
,
\
from
scipost.models
import
TOTPDevice
,
Contributor
,
Remark
,
\
AuthorshipClaim
,
PrecookedEmail
,
\
EditorialCollege
,
EditorialCollegeFellowship
,
UnavailabilityPeriod
...
...
@@ -17,6 +17,12 @@ from production.admin import ProductionUserInline
from
submissions.models
import
Submission
class
TOTPDeviceAdmin
(
admin
.
ModelAdmin
):
search_fields
=
[
'
user
'
,]
admin
.
site
.
register
(
TOTPDevice
)
admin
.
site
.
register
(
UnavailabilityPeriod
)
...
...
@@ -34,9 +40,16 @@ class ContributorInline(admin.StackedInline):
min_num
=
0
class
TOTPDeviceInline
(
admin
.
StackedInline
):
model
=
TOTPDevice
extra
=
0
min_num
=
0
class
UserAdmin
(
UserAdmin
):
inlines
=
[
ContributorInline
,
TOTPDeviceInline
,
ContactInline
,
ProductionUserInline
]
...
...
This diff is collapsed.
Click to expand it.
scipost/migrations/0027_auto_20190826_0924.py
0 → 100644
+
17
−
0
View file @
33a77c6f
# Generated by Django 2.1.8 on 2019-08-26 07:24
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
scipost
'
,
'
0026_auto_20190522_1120
'
),
]
operations
=
[
migrations
.
AlterModelOptions
(
name
=
'
totpdevice
'
,
options
=
{
'
default_related_name
'
:
'
devices
'
,
'
verbose_name
'
:
'
TOTP Device
'
},
),
]
This diff is collapsed.
Click to expand it.
scipost/models.py
+
1
−
0
View file @
33a77c6f
...
...
@@ -52,6 +52,7 @@ class TOTPDevice(models.Model):
class
Meta
:
default_related_name
=
'
devices
'
verbose_name
=
'
TOTP Device
'
def
__str__
(
self
):
return
'
{}: {}
'
.
format
(
self
.
user
,
self
.
name
)
...
...
This diff is collapsed.
Click to expand it.
scipost/totp.py
+
4
−
4
View file @
33a77c6f
...
...
@@ -23,8 +23,8 @@ class TOTPVerification:
Verify a time-dependent code for a certain User.
"""
try
:
# Try to see if input token is convert
a
ble to integer.
# Do not actually make it a integer, because it'll lo
o
se the leading 0s.
# Try to see if input token is convert
i
ble to integer.
# Do not actually make it a
n
integer, because it'll lose the leading 0s.
assert
int
(
code
)
>
0
except
(
ValueError
,
AssertionError
):
# return False, if token could not be converted to an integer
...
...
@@ -59,8 +59,8 @@ class TOTPVerification:
Independently verify a secret_key/code combination at current time.
"""
try
:
# Try to see if input token is convert
a
ble to integer.
# Do not actually make it a integer, because it'll lo
o
se the leading 0s.
# Try to see if input token is convert
i
ble to integer.
# Do not actually make it a
n
integer, because it'll lose the leading 0s.
assert
int
(
code
)
>
0
except
(
ValueError
,
AssertionError
):
# return False, if token could not be converted to an integer
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment