Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-Core
Commits
96618a38
Commit
96618a38
authored
3 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Add predicate to check if a user has activated two-factor auth
parent
db09888b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!605
Resolve "Define rules to require 2FA for views or parts of them"
Pipeline
#10748
passed
3 years ago
Stage: test
Stage: build
Stage: publish
Stage: docker
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
aleksis/core/util/predicates.py
+7
-0
7 additions, 0 deletions
aleksis/core/util/predicates.py
with
7 additions
and
0 deletions
aleksis/core/util/predicates.py
+
7
−
0
View file @
96618a38
...
...
@@ -5,6 +5,7 @@ from django.contrib.auth.models import User
from
django.db.models
import
Model
from
django.http
import
HttpRequest
from
django_otp
import
user_has_device
from
guardian.backends
import
ObjectPermissionBackend
from
guardian.shortcuts
import
get_objects_for_user
from
rules
import
predicate
...
...
@@ -142,3 +143,9 @@ def contains_site_preference_value(section: str, pref: str, value: str):
return
bool
(
value
in
get_site_preferences
()[
f
"
{
section
}
__
{
pref
}
"
])
return
fn
@predicate
def
has_activated_2fa
(
user
:
User
)
->
bool
:
"""
Check if the user has activated two-factor authentication.
"""
return
user_has_device
(
user
)
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