diff options
author | Horacio Bertorello <svankie@gmail.com> | 2017-06-27 17:43:02 -0300 |
---|---|---|
committer | Horacio Bertorello <svankie@gmail.com> | 2017-06-28 14:37:14 -0300 |
commit | 49957cf55114d75dc2c1e62c71a98aad98866960 (patch) | |
tree | d9db87da54e7313a3e0279a872b0fce58ff0c811 /app/controllers/abuse_reports_controller.rb | |
parent | d3c3200ca967142944d89b725e7dcc660e8e601c (diff) | |
download | gitlab-ce-49957cf55114d75dc2c1e62c71a98aad98866960.tar.gz |
Fix errors caused by attempts to report already blocked or deleted users
Diffstat (limited to 'app/controllers/abuse_reports_controller.rb')
-rw-r--r-- | app/controllers/abuse_reports_controller.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb index 2eac0cabf7a..ed13ead63f9 100644 --- a/app/controllers/abuse_reports_controller.rb +++ b/app/controllers/abuse_reports_controller.rb @@ -1,7 +1,9 @@ class AbuseReportsController < ApplicationController + before_action :set_user, only: [:new] + def new @abuse_report = AbuseReport.new - @abuse_report.user_id = params[:user_id] + @abuse_report.user_id = @user.id @ref_url = params.fetch(:ref_url, '') end @@ -27,4 +29,14 @@ class AbuseReportsController < ApplicationController user_id )) end + + def set_user + @user = User.find_by(id: params[:user_id]) + + if @user.nil? + redirect_to root_path, alert: "Cannot create the abuse report. The user has been deleted." + elsif @user.blocked? + redirect_to @user, alert: "Cannot create the abuse report. This user has been blocked." + end + end end |