From 2b8292aba51ad4a41fa2e05445e3e5e4df6347b6 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 24 May 2024 11:14:57 +0200 Subject: [PATCH] Drop compatibility with Redis < 6.2 --- README.md | 2 +- app/controllers/auth/sessions_controller.rb | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0353a4c675..a0f546a5e8 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Mastodon acts as an OAuth2 provider, so 3rd party apps can use the REST and Stre ### Requirements - **PostgreSQL** 12+ -- **Redis** 4+ +- **Redis** 6.2+ - **Ruby** 3.1+ - **Node.js** 18+ diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 6ed7b2baac..962b78de65 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -183,9 +183,7 @@ class Auth::SessionsController < Devise::SessionsController ) # Only send a notification email every hour at most - return if redis.get("2fa_failure_notification:#{user.id}").present? - - redis.set("2fa_failure_notification:#{user.id}", '1', ex: 1.hour) + return if redis.set("2fa_failure_notification:#{user.id}", '1', ex: 1.hour, get: true).present? UserMailer.failed_2fa(user, request.remote_ip, request.user_agent, Time.now.utc).deliver_later! end