Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 'Add admin's password confirmation validation in system' to v0.26 #11928

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion decidim-system/app/forms/decidim/system/admin_form.rb
Expand Up @@ -12,7 +12,7 @@ class AdminForm < Form
attribute :password_confirmation, String

validates :email, presence: true
validates :password, presence: true, unless: :admin_exists?
validates :password, confirmation: true, presence: true, unless: :admin_exists?
validates :password_confirmation, presence: true, unless: :admin_exists?

validates :password, password: { email: :email }
Expand Down
16 changes: 15 additions & 1 deletion decidim-system/spec/commands/decidim/system/create_admin_spec.rb
Expand Up @@ -42,7 +42,21 @@ module System
end
end

describe "when the admin doesn't exist" do
describe "when the password does not match confirmation" do
let(:params) do
{
email: "email@foo.bar",
password: "GcvV56wHp5tJ",
password_confirmation: "GcvV56wHp5tJ2"
}
end

it "broadcasts invalid" do
expect { command.call }.to broadcast(:invalid)
end
end

describe "when the admin does not exist" do
before do
create(:admin, email: "email@foo.bar")
end
Expand Down