Add filters for suspended accounts
This commit is contained in:
parent
2488162733
commit
f406e01fcf
8 changed files with 35 additions and 12 deletions
|
@ -5,6 +5,8 @@ class AccountsController < ApplicationController
|
|||
|
||||
before_action :set_account
|
||||
before_action :set_link_headers
|
||||
before_action :authenticate_user!, only: [:follow, :unfollow]
|
||||
before_action :check_account_suspension
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
|
@ -50,4 +52,8 @@ class AccountsController < ApplicationController
|
|||
def webfinger_account_url
|
||||
webfinger_url(resource: "acct:#{@account.acct}@#{Rails.configuration.x.local_domain}")
|
||||
end
|
||||
|
||||
def check_account_suspension
|
||||
head 410 if @account.suspended?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,6 +15,7 @@ class ApplicationController < ActionController::Base
|
|||
before_action :store_current_location, except: :raise_not_found, unless: :devise_controller?
|
||||
before_action :set_locale
|
||||
before_action :set_user_activity
|
||||
before_action :check_suspension, if: :user_signed_in?
|
||||
|
||||
def raise_not_found
|
||||
raise ActionController::RoutingError, "No route matches #{params[:unmatched_route]}"
|
||||
|
@ -40,6 +41,10 @@ class ApplicationController < ActionController::Base
|
|||
current_user.touch(:current_sign_in_at) if !current_user.nil? && (current_user.current_sign_in_at.nil? || current_user.current_sign_in_at < 24.hours.ago)
|
||||
end
|
||||
|
||||
def check_suspension
|
||||
head 403 if current_user.account.suspended?
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def not_found
|
||||
|
|
|
@ -5,8 +5,7 @@ class Settings::PreferencesController < ApplicationController
|
|||
|
||||
before_action :authenticate_user!
|
||||
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
def update
|
||||
current_user.settings(:notification_emails).follow = user_params[:notification_emails][:follow] == '1'
|
||||
|
|
|
@ -10,8 +10,7 @@ class Settings::ProfilesController < ApplicationController
|
|||
obfuscate_filename [:account, :avatar]
|
||||
obfuscate_filename [:account, :header]
|
||||
|
||||
def show
|
||||
end
|
||||
def show; end
|
||||
|
||||
def update
|
||||
if @account.update(account_params)
|
||||
|
|
|
@ -6,6 +6,7 @@ class StreamEntriesController < ApplicationController
|
|||
before_action :set_account
|
||||
before_action :set_stream_entry
|
||||
before_action :set_link_headers
|
||||
before_action :check_account_suspension
|
||||
|
||||
def show
|
||||
@type = @stream_entry.activity_type.downcase
|
||||
|
@ -37,4 +38,8 @@ class StreamEntriesController < ApplicationController
|
|||
def set_stream_entry
|
||||
@stream_entry = @account.stream_entries.find(params[:id])
|
||||
end
|
||||
|
||||
def check_account_suspension
|
||||
head 410 if @account.suspended?
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue