mirror of
https://github.com/StefBuwalda/WebTech.git
synced 2025-10-30 03:10:00 +00:00
Fixes squiggle lines
This commit is contained in:
2
app.py
2
app.py
@@ -1,6 +1,6 @@
|
||||
from application import app
|
||||
from flask import redirect, url_for
|
||||
from flask_login import current_user, login_required # type: ignore
|
||||
from flask_login import login_required # type: ignore
|
||||
|
||||
|
||||
# home route
|
||||
|
||||
@@ -7,3 +7,8 @@ class User(db.Model, UserMixin):
|
||||
username = db.Column(db.String(150), unique=True, nullable=False)
|
||||
password = db.Column(db.String(150), nullable=False)
|
||||
is_admin = db.Column(db.Boolean, default=False)
|
||||
|
||||
def __init__(self, username: str, password: str, is_admin: bool = False):
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.is_admin = is_admin
|
||||
|
||||
@@ -5,3 +5,7 @@ class Service(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String, nullable=False)
|
||||
url = db.Column(db.String, nullable=False)
|
||||
|
||||
def __init__(self, name: str, url: str):
|
||||
self.name = name
|
||||
self.url = url
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from flask_login import current_user
|
||||
from typing import Callable, Any
|
||||
from flask_login import current_user # type: ignore
|
||||
from functools import wraps
|
||||
from flask import redirect, url_for, flash
|
||||
|
||||
|
||||
def admin_required(f):
|
||||
def admin_required(f: Callable[..., Any]) -> Callable[..., Any]:
|
||||
@wraps(f)
|
||||
def decorated_function(*args, **kwargs):
|
||||
def decorated_function(*args: ..., **kwargs: ...):
|
||||
if not current_user.is_authenticated:
|
||||
return redirect(url_for("login"))
|
||||
if not current_user.is_admin:
|
||||
|
||||
Reference in New Issue
Block a user