Fix #4541: Possible to create new user while logged in.

This commit is contained in:
evazion
2020-07-13 19:08:45 -05:00
parent ed79b623cc
commit 7f2eaeb02b
2 changed files with 6 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
class UserPolicy < ApplicationPolicy
def create?
!sockpuppet?
user.is_anonymous? && !sockpuppet?
end
def update?

View File

@@ -165,6 +165,11 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_no_enqueued_emails
end
should "not allow logged in users to create a new account" do
post_auth users_path, @user, params: { user: { name: "xxx", password: "xxxxx1", password_confirmation: "xxxxx1" }}
assert_response 403
end
should "create a user with a valid email" do
post users_path, params: { user: { name: "xxx", password: "xxxxx1", password_confirmation: "xxxxx1", email: "webmaster@danbooru.donmai.us" }}