mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Validate unsubscribe key has an associated user (#19262)
* FIX: Validate unsubscribe key has an associated user * Improve error messages
This commit is contained in:
@@ -6,10 +6,11 @@ class EmailController < ApplicationController
|
||||
skip_before_action :check_xhr, :preload_json, :redirect_to_login_if_required
|
||||
|
||||
def unsubscribe
|
||||
key = UnsubscribeKey.find_by(key: params[:key])
|
||||
key = UnsubscribeKey.includes(:user).find_by(key: params[:key])
|
||||
@found = key.present?
|
||||
@key_owner_found = key&.user.present?
|
||||
|
||||
if @found
|
||||
if @found && @key_owner_found
|
||||
UnsubscribeKey
|
||||
.get_unsubscribe_strategy_for(key)
|
||||
&.prepare_unsubscribe_options(self)
|
||||
|
||||
Reference in New Issue
Block a user