mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-02 07:47:32 +00:00
add setting ENABLE_FORCE_2FA_TO_ALL_USERS (#4070)
This commit is contained in:
parent
0232b5cfb5
commit
3fa9f80432
@ -759,6 +759,7 @@ CLOUD_DEMO_USER = 'demo@seafile.com'
|
||||
ENABLE_TWO_FACTOR_AUTH = False
|
||||
OTP_LOGIN_URL = '/profile/two_factor_authentication/setup/'
|
||||
TWO_FACTOR_DEVICE_REMEMBER_DAYS = 90
|
||||
ENABLE_FORCE_2FA_TO_ALL_USERS = False
|
||||
|
||||
# Enable personal wiki, group wiki
|
||||
ENABLE_WIKI = True
|
||||
|
@ -9,7 +9,7 @@ from django.http import HttpResponseRedirect
|
||||
from . import DEVICE_ID_SESSION_KEY
|
||||
from .models import Device
|
||||
from seahub.options.models import UserOptions
|
||||
from seahub.settings import SITE_ROOT
|
||||
from seahub.settings import SITE_ROOT, ENABLE_FORCE_2FA_TO_ALL_USERS
|
||||
|
||||
|
||||
class IsVerified(object):
|
||||
@ -85,10 +85,11 @@ class ForceTwoFactorAuthMiddleware(object):
|
||||
if not self.filter_request(request):
|
||||
return None
|
||||
|
||||
if not UserOptions.objects.is_force_2fa(user.username):
|
||||
return None
|
||||
|
||||
if user.otp_device is not None:
|
||||
return None
|
||||
|
||||
return HttpResponseRedirect(reverse('two_factor:setup'))
|
||||
if ENABLE_FORCE_2FA_TO_ALL_USERS or UserOptions.objects.is_force_2fa(user.username):
|
||||
return HttpResponseRedirect(reverse('two_factor:setup'))
|
||||
|
||||
return None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user