From 8b5dc9190d112081be41f89cbe73f5e5d32da070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Casaj=C3=BAs?= Date: Wed, 9 Oct 2024 11:13:49 +0200 Subject: [PATCH] Only change the profile picture if data is sent (#2255) * Only change the profile picture if data is sent * Ensure email is sent * re-use var * Ensure email is given on login * Remove arm from build images * reverted login changes --- .github/workflows/main.yml | 2 +- app/api/views/auth.py | 8 ++++++-- app/api/views/user_info.py | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 360a4ba5..b14160a0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -163,7 +163,7 @@ jobs: uses: docker/build-push-action@v3 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} diff --git a/app/api/views/auth.py b/app/api/views/auth.py index a22b30df..c1cacefd 100644 --- a/app/api/views/auth.py +++ b/app/api/views/auth.py @@ -52,8 +52,12 @@ def auth_login(): password = data.get("password") device = data.get("device") - email = sanitize_email(data.get("email")) - canonical_email = canonicalize_email(data.get("email")) + email = data.get("email") + if not email: + LoginEvent(LoginEvent.ActionType.failed, LoginEvent.Source.api).send() + return jsonify(error="Email or password incorrect"), 400 + email = sanitize_email(email) + canonical_email = canonicalize_email(email) user = User.get_by(email=email) or User.get_by(email=canonical_email) diff --git a/app/api/views/user_info.py b/app/api/views/user_info.py index 44c530d5..e52e05a2 100644 --- a/app/api/views/user_info.py +++ b/app/api/views/user_info.py @@ -87,7 +87,7 @@ def update_user_info(): File.delete(file.id) s3.delete(file.path) Session.flush() - else: + if data["profile_picture"] is not None: raw_data = base64.decodebytes(data["profile_picture"].encode()) if detect_image_format(raw_data) == ImageFormat.Unknown: return jsonify(error="Unsupported image format"), 400