feat: 初始版本,圆角主题与首次管理员引导
This commit is contained in:
18
app/cli.py
Normal file
18
app/cli.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from werkzeug.security import generate_password_hash
|
||||
from .extensions import db
|
||||
from .models import User, Profile, UserStatus
|
||||
|
||||
def register_cli(app):
|
||||
@app.cli.command("create-admin")
|
||||
def create_admin():
|
||||
email = "admin@example.com"
|
||||
username = "admin"
|
||||
password = "admin123"
|
||||
exist = User.query.filter_by(email=email).first()
|
||||
if exist:
|
||||
return
|
||||
u = User(email=email, username=username, password_hash=generate_password_hash(password), role="admin", status=UserStatus.approved)
|
||||
db.session.add(u)
|
||||
db.session.flush()
|
||||
db.session.add(Profile(user_id=u.id))
|
||||
db.session.commit()
|
||||
Reference in New Issue
Block a user