-
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
#156874253 Decode token and return User Details #26
Conversation
I am curious, why have you included pull request template here. |
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.
@JoyLubega Thanks for the great work, kindly ensure checks are passing, thanks.
Am still working on making sure that circleci passes, Because my tests run fine on the local machine |
1 similar comment
Some help needed, to make circleCI pass I had to hard code the secret key in my work. CircleCI couldn't pick it from the env. |
@JoyLubega see @dkam26 to add that environment variable on CircleCI for the mrm project. |
FInally, CircleCI is Passing |
@PatrickCmd I have removed the print statements |
aaa8b60
to
3bb59af
Compare
Pull Request Test Coverage Report for Build 357
💛 - Coveralls |
01fe156
to
37e94ed
Compare
37e94ed
to
ecd52f2
Compare
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.
unnecesary for the sake of this task
@shemogumbe , Help me elaborate on what is unnecessary |
admin_schema.py
Outdated
@@ -0,0 +1,21 @@ | |||
import graphene |
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.
User model not necesary for the sake of decoding a token received from front end as part of response headers
api/user/models.py
Outdated
@@ -0,0 +1,14 @@ | |||
from sqlalchemy import ( |
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.
For the sake of the task 'decoding token'this model is not necesary
api/user/models.py
Outdated
from utilities.utility import Utility | ||
|
||
|
||
class User(Base, Utility): |
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.
Not necesary for the sake of decoding token
api/user/schema.py
Outdated
return query.filter(UserModel.email == email).first() | ||
|
||
|
||
class Mutation(graphene.ObjectType): |
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.
Not necesary for purposes of the task decoding token
helpers/auth/decode_token.py
Outdated
is_admin | ||
""" | ||
|
||
def verify(self, token): |
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.
Makes sense, issues is, where does the token come from , does not seem like it comes from the request headers?
helpers/auth/decode_token.py
Outdated
except jwt.InvalidTokenError: | ||
return jsonify({ 'message': 'Invalid token. Please Provide a valid token!'}), 401 | ||
|
||
def is_admin(self, token): |
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.
This is not necesary for now, we are not yet at the stage of permissions yet
helpers/auth/decode_token.py
Outdated
|
||
|
||
def resolve_token(self, info): | ||
print(info) |
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.
print statements should not be pushed, please remove them.
helpers/auth/decode_token.py
Outdated
SECRET_KEY = os.getenv('SECRET_KEY') | ||
try: | ||
payload = jwt.decode(auth_token, verify=False) | ||
print(payload) |
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.
Same as above.
What does this PR do?
This PR decode the token and returns user's Name and email
Description of Task to be completed?
How should this be manually tested?
N/A
Any background context you want to provide?
What are the relevant Pivotal Tracker board stories?
#156874253
Screenshots (if appropriate)