Limit amount of imports (#1161)

* Limit amount of imports

* Review suggestions

* Format

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
Adrià Casajús 2022-07-16 18:17:15 +02:00 committed by GitHub
parent bcd4383e05
commit 2837350204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -28,6 +28,15 @@ def batch_import_route():
batch_imports = BatchImport.filter_by(user_id=current_user.id).all()
if request.method == "POST":
if len(batch_imports) > 10:
flash(
"You have too many imports already. Wait until some get cleaned up",
"error",
)
return render_template(
"dashboard/batch_import.html", batch_imports=batch_imports
)
alias_file = request.files["alias-file"]
file_path = random_string(20) + ".csv"

View File

@ -204,9 +204,10 @@ def create_app() -> Flask:
@login_manager.user_loader
def load_user(alternative_id):
user = User.get_by(alternative_id=alternative_id)
if user and user.disabled:
return None
sentry_sdk.set_user({"email": user.email, "id": user.id})
if user:
sentry_sdk.set_user({"email": user.email, "id": user.id})
if user.disabled:
return None
return user