FIX: raise `Discourse::NotFound` unless the user is present

FIX: raise Discourse::NotFound unless the user is present

From 61eff22b29c434b94b355e9a10bc18eb4be93e6d Mon Sep 17 00:00:00 2001
From: Arpit Jalan <arpit@techapj.com>
Date: Wed, 21 Nov 2018 10:57:42 +0530
Subject: [PATCH] FIX: raise `Discourse::NotFound` unless the user is present


diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb
index ae1ecff..887796e 100644
--- a/app/controllers/topics_controller.rb
+++ b/app/controllers/topics_controller.rb
@@ -500,9 +500,10 @@ class TopicsController < ApplicationController
   def remove_allowed_user
     params.require(:username)
     topic = Topic.find_by(id: params[:topic_id])
+    raise Discourse::NotFound unless topic
     user = User.find_by(username: params[:username])
+    raise Discourse::NotFound unless user
 
-    raise Discourse::NotFound unless topic
     guardian.ensure_can_remove_allowed_users!(topic, user)
 
     if topic.remove_allowed_user(current_user, user)

GitHub