Skip to content
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

Closed
wants to merge 23 commits into from

Conversation

JoyLubega
Copy link
Contributor

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)

screen shot 2018-05-17 at 01 40 16

screen shot 2018-05-17 at 00 37 53

@PatrickCmd
Copy link
Contributor

I am curious, why have you included pull request template here.

Copy link
Contributor

@owenbob owenbob left a 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.

@JoyLubega
Copy link
Contributor Author

Am still working on making sure that circleci passes, Because my tests run fine on the local machine

@JoyLubega
Copy link
Contributor Author

##Screenshots
screen shot 2018-05-23 at 23 38 56

1 similar comment
@JoyLubega
Copy link
Contributor Author

##Screenshots
screen shot 2018-05-23 at 23 38 56

@JoyLubega
Copy link
Contributor Author

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.

@PatrickCmd
Copy link
Contributor

@JoyLubega see @dkam26 to add that environment variable on CircleCI for the mrm project.

@JoyLubega
Copy link
Contributor Author

FInally, CircleCI is Passing

@JoyLubega
Copy link
Contributor Author

@PatrickCmd I have removed the print statements

@JoyLubega JoyLubega force-pushed the ft-intergrate-andela-platform-156874253 branch from aaa8b60 to 3bb59af Compare May 31, 2018 10:04
@coveralls
Copy link

coveralls commented May 31, 2018

Pull Request Test Coverage Report for Build 357

  • 45 of 47 (95.74%) changed or added relevant lines in 3 files are covered.
  • 7 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-3.3%) to 96.739%

Changes Missing Coverage Covered Lines Changed/Added Lines %
helpers/auth/decode_token.py 32 34 94.12%
Files with Coverage Reduction New Missed Lines %
api/room/schema.py 1 98.04%
api/floor/schema.py 2 81.82%
api/block/schema.py 2 87.5%
api/room_resource/schema.py 2 75.0%
Totals Coverage Status
Change from base Build 350: -3.3%
Covered Lines: 267
Relevant Lines: 276

💛 - Coveralls

@JoyLubega JoyLubega force-pushed the ft-intergrate-andela-platform-156874253 branch from 01fe156 to 37e94ed Compare June 7, 2018 09:51
@JoyLubega JoyLubega force-pushed the ft-intergrate-andela-platform-156874253 branch from 37e94ed to ecd52f2 Compare June 7, 2018 11:15
Copy link
Contributor

@shemogumbe shemogumbe left a 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

@JoyLubega
Copy link
Contributor Author

@shemogumbe , Help me elaborate on what is unnecessary

admin_schema.py Outdated
@@ -0,0 +1,21 @@
import graphene
Copy link
Contributor

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

@@ -0,0 +1,14 @@
from sqlalchemy import (
Copy link
Contributor

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

from utilities.utility import Utility


class User(Base, Utility):
Copy link
Contributor

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

return query.filter(UserModel.email == email).first()


class Mutation(graphene.ObjectType):
Copy link
Contributor

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

is_admin
"""

def verify(self, token):
Copy link
Contributor

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?

except jwt.InvalidTokenError:
return jsonify({ 'message': 'Invalid token. Please Provide a valid token!'}), 401

def is_admin(self, token):
Copy link
Contributor

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



def resolve_token(self, info):
print(info)
Copy link
Contributor

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.

SECRET_KEY = os.getenv('SECRET_KEY')
try:
payload = jwt.decode(auth_token, verify=False)
print(payload)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above.

@JoyLubega JoyLubega closed this Jun 11, 2018
@shemogumbe shemogumbe deleted the ft-intergrate-andela-platform-156874253 branch October 29, 2018 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants