This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
devicehub-teal/ereuse_devicehub/commands/users.py

21 lines
531 B
Python
Raw Normal View History

2022-07-22 15:49:51 +00:00
import click
from ereuse_devicehub import auth
from ereuse_devicehub.resources.user.models import User
class GetToken:
def __init__(self, app) -> None:
super().__init__()
self.app = app
self.app.cli.command('get_token', short_help='show the user token.')(
self.run
)
@click.argument('email')
def run(self, email):
user = User.query.filter_by(email=email, active=True, phantom=False).one_or_none()
if user:
print(auth.Auth.encode(user.token))