Add user auth, personal cabinet, admin panel and first admin bootstrap

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-06 22:20:09 +03:00
parent c6a7ecfc4c
commit 61e7290ce8
26 changed files with 1351 additions and 108 deletions
+28
View File
@@ -0,0 +1,28 @@
from functools import wraps
from flask import abort, flash, redirect, url_for
from flask_login import current_user
def admin_required(f):
@wraps(f)
def decorated(*args, **kwargs):
if not current_user.is_authenticated or not current_user.is_admin:
flash("Доступ только для администраторов", "error")
return redirect(url_for("main.index"))
return f(*args, **kwargs)
return decorated
def can_manage_photo(photo):
if not current_user.is_authenticated:
return False
if current_user.is_admin:
return True
return photo.user_id == current_user.id
def photo_owner_or_admin(photo):
if not can_manage_photo(photo):
abort(403)