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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow apostrophes in email address #12729

Merged
merged 1 commit into from
Nov 17, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class User < ApplicationRecord

validates_presence_of :name, :userid
validates :userid, :uniqueness => {:conditions => -> { in_my_region } }
validates_format_of :email, :with => /\A([\w\.\-\+]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i,
validates_format_of :email, :with => /\A([\w\.\-\+']+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@imtayadeway @gtanzillo Maybe this regex should be used, instead?

:allow_nil => true, :message => "must be a valid email address"
validates_inclusion_of :current_group, :in => proc { |u| u.miq_groups }, :allow_nil => true

Expand Down
4 changes: 4 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
it "should reject invalid characters in email address" do
expect(FactoryGirl.build(:user, :email => "{{that.guy}}@manageiq.com")).not_to be_valid
end

it "allows apostrophes in email address" do
expect(FactoryGirl.build(:user, :email => "timmy.o'[email protected]")).to be_valid
end
end

describe "#change_password" do
Expand Down