forked from hotosm/tasking-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
27 lines (19 loc) · 816 Bytes
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import base64
from flask_migrate import MigrateCommand
from flask_script import Manager
from server import create_app
from server.services.users.authentication_service import AuthenticationService
# Initialise the flask app object
application = create_app()
manager = Manager(application)
# Enable db migrations to be run via the command line
manager.add_command('db', MigrateCommand)
@manager.option('-u', '--user_id', help='Test User ID')
def gen_token(user_id):
""" Helper method for generating valid base64 encoded session tokens """
token = AuthenticationService.generate_session_token_for_user(user_id)
print(f'Raw token is: {token}')
b64_token = base64.b64encode(token.encode())
print(f'Your base64 encoded session token: {b64_token}')
if __name__ == '__main__':
manager.run()