-
-
Notifications
You must be signed in to change notification settings - Fork 247
Fix for #74 do not fail with empty request to /auth #75
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
Conversation
…so using request.get_json()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a couple of minor tweaks, if you don't mind addressing them. Thanks for contributing! :)
examples/simple.py
Outdated
|
|
||
| if request.is_json: | ||
| params = request.get_json() | ||
| if 'username' in params.keys() and 'password' in params.keys(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change this to not use .keys()? Doing 'username' in params is more efficient (at least with python2), as .keys() makes a copy of the keys into a list, which you then have to iterate through (O(n) instead of O(1))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
| ret = {'access_token': create_access_token(identity=params['username'])} | ||
| return jsonify(ret), 200 | ||
| else: | ||
| return jsonify({"msg": "Missing auth"}), 401 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to avoid a bunch of nested if's, can you lift this to the top? Something like
if not request.is_json:
return jsonify({"msg": "Missing auth"}), 401
# rest of the code, but not nested in an if block any more|
Thanks for contributing 👍 |
No description provided.