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

This commit is contained in:
Arpit Jalan 2018-11-21 10:57:42 +05:30
parent 10cc698df3
commit 61eff22b29

View File

@ -500,9 +500,10 @@ class TopicsController < ApplicationController
def remove_allowed_user
params.require(:username)
topic = Topic.find_by(id: params[:topic_id])
user = User.find_by(username: params[:username])
raise Discourse::NotFound unless topic
user = User.find_by(username: params[:username])
raise Discourse::NotFound unless user
guardian.ensure_can_remove_allowed_users!(topic, user)
if topic.remove_allowed_user(current_user, user)