Skip to content

Commit

Permalink
Fix: create JWT token without payload
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Jan 11, 2022
1 parent 16573e6 commit 756d6cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def test_jwtcli():
assert status == 0
assert len(stdout.split('.')) == 3

# Without token
when('auth create')
assert stderr == ''
assert status == 0
assert len(stdout.split('.')) == 3


if __name__ == '__main__':
app.climain(['auth', 'c', '{"foo": "bar"}'])
2 changes: 1 addition & 1 deletion yhttp/ext/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
from .install import install
from .authentication import Authenticator

__version__ = '3.7.0'
__version__ = '3.7.1'
7 changes: 6 additions & 1 deletion yhttp/ext/auth/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ class Create(SubCommand):
def __call__(self, args):
settings = args.application.settings.auth
jwt = Authenticator(settings)
print(jwt.dump(json.loads(args.payload)))
if args.payload:
payload = json.loads(args.payload)
else:
payload = ''

print(jwt.dump(payload))


class AuthenticatorCLI(SubCommand):
Expand Down

0 comments on commit 756d6cf

Please sign in to comment.