forked from simple-login/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.py
43 lines (32 loc) · 958 Bytes
/
shell.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from time import sleep
import flask_migrate
from IPython import embed
from sqlalchemy_utils import create_database, database_exists, drop_database
from app.config import DB_URI
from app.db import Session
from app.email_utils import send_email, render
from app.log import LOG
from app.models import *
from job_runner import (
onboarding_pgp,
onboarding_browser_extension,
onboarding_mailbox,
onboarding_send_from_alias,
)
def create_db():
if not database_exists(DB_URI):
LOG.d("db not exist, create database")
create_database(DB_URI)
# Create all tables
# Use flask-migrate instead of db.create_all()
flask_migrate.upgrade()
def change_password(user_id, new_password):
user = User.get(user_id)
user.set_password(new_password)
Session.commit()
def reset_db():
if database_exists(DB_URI):
drop_database(DB_URI)
create_db()
if __name__ == "__main__":
embed()