mirror of
https://github.com/Cian-H/invenio-config-iform.git
synced 2025-12-23 05:21:57 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
087cafa3ae | ||
|
|
14e9e0557a |
@@ -7,6 +7,11 @@
|
|||||||
|
|
||||||
Changes
|
Changes
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
Version v0.10.1 (release 2022-11-17)
|
||||||
|
|
||||||
|
- global: add function
|
||||||
|
|
||||||
Version 0.10.0 (released 2022-10-13)
|
Version 0.10.0 (released 2022-10-13)
|
||||||
|
|
||||||
- global: migrate to v10 (#101)
|
- global: migrate to v10 (#101)
|
||||||
|
|||||||
@@ -10,7 +10,13 @@
|
|||||||
|
|
||||||
from .ext import InvenioConfigTugraz
|
from .ext import InvenioConfigTugraz
|
||||||
from .generators import RecordIp
|
from .generators import RecordIp
|
||||||
|
from .utils import get_identity_from_user_by_email
|
||||||
|
|
||||||
__version__ = "0.10.0"
|
__version__ = "0.10.1"
|
||||||
|
|
||||||
__all__ = ("__version__", "InvenioConfigTugraz", "RecordIp")
|
__all__ = (
|
||||||
|
"__version__",
|
||||||
|
"InvenioConfigTugraz",
|
||||||
|
"RecordIp",
|
||||||
|
"get_identity_from_user_by_email",
|
||||||
|
)
|
||||||
|
|||||||
32
invenio_config_tugraz/utils.py
Normal file
32
invenio_config_tugraz/utils.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 Graz University of Technology.
|
||||||
|
#
|
||||||
|
# invenio-config-tugraz is free software; you can redistribute it and/or
|
||||||
|
# modify it under the terms of the MIT License; see LICENSE file for more
|
||||||
|
# details.
|
||||||
|
|
||||||
|
"""Utils file."""
|
||||||
|
|
||||||
|
from flask_principal import Identity
|
||||||
|
from invenio_access import any_user
|
||||||
|
from invenio_access.utils import get_identity
|
||||||
|
from invenio_accounts import current_accounts
|
||||||
|
|
||||||
|
|
||||||
|
def get_identity_from_user_by_email(email: str = None) -> Identity:
|
||||||
|
"""Get the user specified via email or ID."""
|
||||||
|
if email is None:
|
||||||
|
raise ValueError("the email has to be set to get a identity")
|
||||||
|
|
||||||
|
user = current_accounts.datastore.get_user(email)
|
||||||
|
|
||||||
|
if user is None:
|
||||||
|
raise LookupError(f"user with {email} not found")
|
||||||
|
|
||||||
|
identity = get_identity(user)
|
||||||
|
|
||||||
|
# TODO: this is a temporary solution. this should be done with data from the db
|
||||||
|
identity.provides.add(any_user)
|
||||||
|
|
||||||
|
return identity
|
||||||
Reference in New Issue
Block a user