mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 11:19:58 +00:00
123123123
This commit is contained in:
5
app.py
5
app.py
@@ -5,12 +5,11 @@ from flask_login import current_user, login_required
|
|||||||
|
|
||||||
# home route
|
# home route
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
@login_required
|
|
||||||
def index():
|
def index():
|
||||||
if current_user.is_authenticated:
|
if current_user.is_authenticated:
|
||||||
return redirect(url_for("application.dash"))
|
return redirect(url_for("dash.index"))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for("application.auth"))
|
return redirect(url_for("auth.login"))
|
||||||
|
|
||||||
|
|
||||||
# App deployment
|
# App deployment
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ def login():
|
|||||||
user.password, password # type: ignore
|
user.password, password # type: ignore
|
||||||
):
|
):
|
||||||
login_user(user) # type: ignore
|
login_user(user) # type: ignore
|
||||||
return redirect(url_for("application.dash"))
|
return redirect("/")
|
||||||
else:
|
else:
|
||||||
feedback = "Foutieve login."
|
feedback = "Foutieve login."
|
||||||
|
|
||||||
|
|||||||
24
seed.py
Normal file
24
seed.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from application import db, app
|
||||||
|
from application.dash.models import Service
|
||||||
|
from application.auth.models import User
|
||||||
|
from werkzeug.security import generate_password_hash
|
||||||
|
|
||||||
|
"""
|
||||||
|
new_strikers = [
|
||||||
|
se(name="Erik", strike="y", age=44),
|
||||||
|
Striker(name="Henk", strike="n", age=88),
|
||||||
|
]
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
new_user = User(username="admin", password=generate_password_hash("admin"))
|
||||||
|
|
||||||
|
with app.app_context():
|
||||||
|
# Remove all existing
|
||||||
|
Service.query.delete()
|
||||||
|
User.query.delete()
|
||||||
|
db.session.commit()
|
||||||
|
# Then add new
|
||||||
|
# db.session.add_all(new_strikers)
|
||||||
|
db.session.add(new_user)
|
||||||
|
db.session.commit()
|
||||||
Reference in New Issue
Block a user