mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-29 19:00:00 +00:00
Removed any errors by ignoring them
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from flask import Blueprint, render_template, redirect, url_for, flash
|
||||
from flask import Blueprint, render_template, redirect, url_for
|
||||
|
||||
# from application import db
|
||||
from application.auth.models import User
|
||||
@@ -36,5 +36,4 @@ def login():
|
||||
@login_required
|
||||
def logout():
|
||||
logout_user()
|
||||
flash("Je bent nu uitgelogd.")
|
||||
return redirect(url_for("index"))
|
||||
|
||||
@@ -42,8 +42,8 @@ def admin():
|
||||
feedback="Username is already taken",
|
||||
)
|
||||
new_user = User(
|
||||
username=username,
|
||||
password=generate_password_hash(password),
|
||||
username=username, # type: ignore
|
||||
password=generate_password_hash(password), # type: ignore
|
||||
is_admin=is_admin,
|
||||
)
|
||||
db.session.add(new_user)
|
||||
@@ -61,10 +61,14 @@ def admin():
|
||||
def service():
|
||||
service_form = ServiceForm()
|
||||
|
||||
if service_form.validate_on_submit():
|
||||
if service_form.validate_on_submit(): # type: ignore
|
||||
name = service_form.name.data
|
||||
url = service_form.url.data
|
||||
new_service = Service(name=name, url=url, user_id=current_user.id)
|
||||
new_service = Service(
|
||||
name=name, # type: ignore
|
||||
url=url, # type: ignore
|
||||
user_id=current_user.id,
|
||||
)
|
||||
db.session.add(new_service)
|
||||
db.session.commit()
|
||||
return render_template(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Callable, Any
|
||||
from flask_login import current_user # type: ignore
|
||||
from functools import wraps
|
||||
from flask import redirect, url_for, flash
|
||||
from flask import redirect, url_for
|
||||
|
||||
|
||||
def admin_required(f: Callable[..., Any]) -> Callable[..., Any]:
|
||||
@@ -10,7 +10,6 @@ def admin_required(f: Callable[..., Any]) -> Callable[..., Any]:
|
||||
if not current_user.is_authenticated:
|
||||
return redirect(url_for("login"))
|
||||
if not current_user.is_admin:
|
||||
flash("Admins only!")
|
||||
return redirect(url_for("index"))
|
||||
return f(*args, **kwargs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user