mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 14:42:10 +00:00
update search user logic when login via shib (#4708)
Co-authored-by: lian <lian@seafile.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connection
|
|
||||||
|
|
||||||
from seaserv import ccnet_api
|
from seaserv import ccnet_api
|
||||||
from seahub.auth.backends import RemoteUserBackend
|
from seahub.auth.backends import RemoteUserBackend
|
||||||
@@ -7,6 +6,7 @@ from seahub.base.accounts import User
|
|||||||
from registration.models import (
|
from registration.models import (
|
||||||
notify_admins_on_activate_request, notify_admins_on_register_complete)
|
notify_admins_on_activate_request, notify_admins_on_register_complete)
|
||||||
|
|
||||||
|
|
||||||
class ShibbolethRemoteUserBackend(RemoteUserBackend):
|
class ShibbolethRemoteUserBackend(RemoteUserBackend):
|
||||||
"""
|
"""
|
||||||
This backend is to be used in conjunction with the ``RemoteUserMiddleware``
|
This backend is to be used in conjunction with the ``RemoteUserMiddleware``
|
||||||
@@ -49,6 +49,9 @@ class ShibbolethRemoteUserBackend(RemoteUserBackend):
|
|||||||
if not local_ccnet_users:
|
if not local_ccnet_users:
|
||||||
local_ccnet_users = ccnet_api.search_emailusers('LDAP', username, -1, -1)
|
local_ccnet_users = ccnet_api.search_emailusers('LDAP', username, -1, -1)
|
||||||
|
|
||||||
|
if username not in [item.email for item in local_ccnet_users]:
|
||||||
|
local_ccnet_users = []
|
||||||
|
|
||||||
if not local_ccnet_users:
|
if not local_ccnet_users:
|
||||||
if self.create_unknown_user:
|
if self.create_unknown_user:
|
||||||
user = User.objects.create_user(
|
user = User.objects.create_user(
|
||||||
|
Reference in New Issue
Block a user