neo4j-graphacademy / app-python

https://graphacademy.neo4j.com/courses/app-python
56 stars 92 forks source link

The decode method is not needed in _generate_token() #14

Closed ghost closed 1 year ago

ghost commented 1 year ago

The test for the Python Applications course https://graphacademy.neo4j.com/courses/app-python/2-interacting/5-registering/ will fail on this script for reasons outside the scope of the lesson. The root cause is the _generate_token() method.

 def _generate_token(self, payload):
      iat = datetime.utcnow()

      payload["sub"] = payload["userId"]
      payload["iat"] = iat
      payload["nbf"] = iat
      payload["exp"] = iat + current_app.config.get('JWT_EXPIRATION_DELTA')

      return jwt.encode(
          payload,
          self.jwt_secret,
          algorithm='HS256'
      ).decode('ascii')

The .decode('ascii') should be removed in the Main branch that users initially clone.

ghost commented 1 year ago

Pull request opened for this issue: https://github.com/neo4j-graphacademy/app-python/pull/15

adam-cowley commented 1 year ago

Thanks for spotting this. I have subsequently updated the code on all branches