inveniosoftware / invenio-access

Invenio module for common role based access control.
https://invenio-access.readthedocs.io
MIT License
3 stars 49 forks source link

Allow `AnonymousIdentity` for `get_identity()` utils functions #187

Open zannkukai opened 2 years ago

zannkukai commented 2 years ago

Is your feature request related to a problem? Please describe.

the https://github.com/inveniosoftware/invenio-access/blob/87dde7f6b43bda41ec2115ef4a358442d8136703/invenio_access/utils.py#L14 method could be return a value even for AnonymousUser

Describe the solution you'd like

Check if user is an anonymous. If yes, return a flask_login.AnonymousIdentity instance.

    if not user.is_anonymous:
        return AnonymousIdentity()

I will be happy to contribute if you valid this feature.