added user registration and login
This commit is contained in:
20
create_default_user.py
Normal file
20
create_default_user.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from app import app, db, User, bcrypt
|
||||
|
||||
# Create the default user
|
||||
username = 'admin'
|
||||
password = '1234'
|
||||
hashed_password = bcrypt.generate_password_hash(password).decode('utf-8')
|
||||
|
||||
with app.app_context():
|
||||
# Delete the existing user if it exists
|
||||
existing_user = User.query.filter_by(username=username).first()
|
||||
if existing_user:
|
||||
db.session.delete(existing_user)
|
||||
db.session.commit()
|
||||
|
||||
# Add the new user to the database
|
||||
default_user = User(username=username, password=hashed_password, role='admin')
|
||||
db.session.add(default_user)
|
||||
db.session.commit()
|
||||
|
||||
print(f"Default user '{username}' created with password '{password}'")
|
||||
Reference in New Issue
Block a user