login flow through ui
This commit is contained in:
parent
a481ae9526
commit
41f36b0fd7
8 changed files with 164 additions and 4 deletions
0
roc_fnb/scripts/__init__.py
Normal file
0
roc_fnb/scripts/__init__.py
Normal file
24
roc_fnb/scripts/bootstrap_first_admin.py
Normal file
24
roc_fnb/scripts/bootstrap_first_admin.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from click import command, option, prompt, confirm
|
||||
from roc_fnb.website.database import Database
|
||||
from roc_fnb.website.models.user import User
|
||||
|
||||
|
||||
@command
|
||||
@option('--name', '-n', type=str, required=True)
|
||||
@option('--email', '-e', type=str, required=True)
|
||||
def bootstrap_first_admin(name: str, email: str):
|
||||
password = prompt('Enter the account password',
|
||||
hide_input=True, prompt_suffix=': ')
|
||||
confirmation = prompt('Confirm the account password',
|
||||
hide_input=True, prompt_suffix=': ')
|
||||
if password != confirmation:
|
||||
raise ValueError('passwords did not match')
|
||||
admin = User.create(email, name, password, moderator=True, admin=True)
|
||||
db = Database.from_env()
|
||||
db.store_user(admin)
|
||||
if confirm('Display an auth token for testing?', default=False):
|
||||
print(admin.jwt)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
bootstrap_first_admin()
|
||||
Loading…
Add table
Add a link
Reference in a new issue