-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cognito_group_permissions not working #16
Comments
Had a quick look, seems like the name of the decorator in the module doesn't match that in the read me. It's looks to have been mismatched since ~ PR #9. I've made a branch which duplicates the decorator under the name that matches the readme me and adds a few tests, alternatively the readme could be updated to reflect the name in the code. @revmischa how do you want to handle the mismatch between the name in the code in the readme to avoid breaking things for other users who might be using the current decorator name? |
Here's the branch for reference: https://github.com/aaronbrown1988/flask_cognito/tree/fix-group-decorator-name |
Up to you, can you just export a variable that is an alias of the existing decorator? |
Sure, that would work. I've created a PR with the change here: #17 |
Hi, I have encountered the same issue, in a slightly different way. First of all, @aaronbrown1988 thanks for your solution! But I'm afraid it's not enough, you see, the decorator generator always returns the same function and that's lead to the same function being registered on different flask routes (which is impossible). so I think we should change this code: def cognito_check_groups(groups: list):
def decorator(function):
def wrapper(*args, **kwargs):
_cognito_check_groups(groups)
return function(*args, **kwargs)
return wrapper
return decorator to use python def cognito_check_groups(groups: list):
def decorator(function):
@wraps(function)
def wrapper(*args, **kwargs):
_cognito_check_groups(groups)
return function(*args, **kwargs)
return wrapper
return decorator This way the wrapper function will be patched to have the original metadata. |
I'm trying to use the cognito_group_permissions decorator but isn't working...
Traceback (most recent call last):
File "main.py", line 5, in
from flask_cognito import CognitoAuth, cognito_group_permissions
ImportError: cannot import name 'cognito_group_permissions' from 'flask_cognito' (C:\Users\Cairo\anaconda3\envs\salt\lib\site-packages\flask_cognito.py)
The text was updated successfully, but these errors were encountered: