emails: fix exception when disabling dmail notifications.

Fix an `undefined method 'find' for Maintenance::User:Module` exception
when disabling email notifications using the "Disable notifications"
link in dmails.
This commit is contained in:
evazion
2022-01-02 17:08:31 -06:00
parent e40218d1c8
commit 370ed32426
2 changed files with 43 additions and 3 deletions

View File

@@ -5,6 +5,8 @@ module Maintenance
class EmailNotificationsController < ApplicationController
class VerificationError < StandardError; end
respond_to :html, :json, :xml
before_action :validate_sig, :only => [:destroy]
rescue_from VerificationError, with: :render_verification_error
@@ -12,9 +14,9 @@ module Maintenance
end
def destroy
@user = User.find(params[:user_id])
@user.receive_email_notifications = false
@user.save
@user = ::User.find(params[:user_id])
@user.update!(receive_email_notifications: false)
respond_with(@user)
end
private