use a merged store when there is no known collectivity, just for
get_identity_for_name_identifier (for soap endpoints)
This commit is contained in:
parent
c2ec9b5a77
commit
aab88d25a7
|
@ -68,9 +68,13 @@ class AlternateRootDirectory(OldRootDirectory):
|
|||
t = OldRootDirectory._q_traverse(self, path)
|
||||
federated_with_msp = ''
|
||||
if get_session() and get_session().user:
|
||||
identity = identities.get_store().get_identity(get_session().user)
|
||||
if identity.is_federated_with_msp():
|
||||
federated_with_msp = 'plop' # any value will do
|
||||
try:
|
||||
identity = identities.get_store().get_identity(get_session().user)
|
||||
except KeyError:
|
||||
get_session_manager().expire_session()
|
||||
else:
|
||||
if identity.is_federated_with_msp():
|
||||
federated_with_msp = 'plop' # any value will do
|
||||
get_response().filter['federated_with_msp'] = federated_with_msp
|
||||
get_response().filter['msp_session_image_url'] = get_cfg('adeline', {}).get(
|
||||
'msp_session_image_url', '')
|
||||
|
|
|
@ -2,20 +2,43 @@ from quixote import get_session, get_session_manager, get_request, get_publisher
|
|||
|
||||
import authentic.identities
|
||||
|
||||
import collectivity
|
||||
|
||||
|
||||
class MergedIdentityStore(authentic.identities.IdentitiesStoreStorage):
|
||||
def get_identity_for_name_identifier(self, name_identifier):
|
||||
x = authentic.identities.IdentitiesStoreStorage.get_identity_for_name_identifier(
|
||||
self, name_identifier)
|
||||
if x:
|
||||
return x
|
||||
|
||||
for coll in collectivity.Collectivity.select():
|
||||
store = get_collectivity_store(coll.id)
|
||||
x = store.get_identity_for_name_identifier(name_identifier)
|
||||
if x:
|
||||
return x
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_collectivity_identity_class(collectivity_id):
|
||||
class CollectivityIdentity(authentic.identities.Identity):
|
||||
_names = 'identities-' + str(collectivity_id)
|
||||
return CollectivityIdentity
|
||||
|
||||
|
||||
def load_store():
|
||||
coll_id = get_request().get_header('X-Gdd-Account-Number')
|
||||
if coll_id == '547263': # Parthenay
|
||||
def get_collectivity_store(collectivity_id):
|
||||
if collectivity_id == '547263': # Parthenay
|
||||
raise NotImplementedError()
|
||||
elif coll_id:
|
||||
elif collectivity_id:
|
||||
# Vandoeuvre (546555) and others
|
||||
store = authentic.identities.IdentitiesStoreStorage(
|
||||
identity_class = get_collectivity_identity_class(coll_id))
|
||||
identity_class = get_collectivity_identity_class(collectivity_id))
|
||||
else:
|
||||
store = authentic.identities.IdentitiesStoreStorage()
|
||||
get_publisher().store = store
|
||||
store = MergedIdentityStore()
|
||||
return store
|
||||
|
||||
|
||||
def load_store():
|
||||
coll_id = get_request().get_header('X-Gdd-Account-Number')
|
||||
get_publisher().store = get_collectivity_store(coll_id)
|
||||
|
|
Reference in New Issue