Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

check that user model has roles attr on user create #739

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Jaza
Copy link
Contributor

@Jaza Jaza commented Dec 31, 2017

No description provided.

Copy link
Contributor

@jirikuncar jirikuncar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add new tests. Thanks!

roles[i] = self.find_role(rn)
kwargs['roles'] = roles

if hasattr(self.user_model, 'roles'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather see an exception if you try to save user with roles.

if not hasattr(self.user_model, 'roles') and kwargs.get('roles'):
    raise  # custom Flask-Security exception

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok @jirikuncar, now raising an exception as you suggested, and have added tests.

Sorry it took me a whole year to respond to your feedback. Anyway, better late than never!

@jwag956
Copy link
Collaborator

jwag956 commented Apr 30, 2019

If you are doing all this checking - would it make sense to exception if role doesn't exist - rather than just ignoring it? That would seem like a equally bad 'admin/config' error...

jasco pushed a commit to jasco/flask-security that referenced this pull request Oct 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants