Skip to content

Commit

Permalink
[webui] Drop validation of user's email address
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken committed Apr 19, 2017
1 parent a6d550f commit 1c264f5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/api/app/models/user.rb
Expand Up @@ -53,7 +53,7 @@ class User < ApplicationRecord

scope :all_without_nobody, -> { where("login != ?", nobody_login) }

validates :login, :email, :password, :password_hash_type, :state,
validates :login, :password, :password_hash_type, :state,
presence: { message: 'must be given' }

validates :login,
Expand All @@ -73,8 +73,9 @@ class User < ApplicationRecord
# However, this is not *so* bad since users have to answer on their email
# to confirm their registration.
validates :email,
format: { with: %r{\A([\w\-\.\#\$%&!?*\'\+=(){}|~]+)@([0-9a-zA-Z\-\.\#\$%&!?*\'=(){}|~]+)+\z},
message: 'must be a valid email address.' }
format: { with: %r{\A([\w\-\.\#\$%&!?*\'\+=(){}|~]+)@([0-9a-zA-Z\-\.\#\$%&!?*\'=(){}|~]+)+\z},
message: 'must be a valid email address.',
allow_blank: true }

# We want to validate the format of the password and only allow alphanumeric
# and some punctiation/base64 characters.
Expand Down
4 changes: 2 additions & 2 deletions src/api/spec/controllers/webui/user_controller_spec.rb
Expand Up @@ -125,11 +125,11 @@
context "with invalid data" do
before do
login user
post :save, params: { user: user, realname: "another real name", email: "" }
post :save, params: { user: user, realname: "another real name", email: "invalid" }
user.reload
end

it { expect(flash[:error]).to eq("Couldn't update user: Validation failed: Email must be given, Email must be a valid email address..") }
it { expect(flash[:error]).to eq("Couldn't update user: Validation failed: Email must be a valid email address..") }
it { expect(user.realname).to eq(user.realname) }
it { expect(user.email).to eq(user.email) }
it { is_expected.to redirect_to user_show_path(user) }
Expand Down
1 change: 0 additions & 1 deletion src/api/spec/models/user_spec.rb
Expand Up @@ -11,7 +11,6 @@
it { is_expected.to validate_length_of(:login).is_at_least(2).with_message('must have more than two characters.') }
it { is_expected.to validate_length_of(:login).is_at_most(100).with_message('must have less than 100 characters.') }

it { is_expected.to validate_presence_of(:email).with_message('must be given') }
it { is_expected.to allow_value('king@opensuse.org').for(:email) }
it { is_expected.to_not allow_values('king.opensuse.org', 'opensuse.org', 'opensuse').for(:email) }

Expand Down

0 comments on commit 1c264f5

Please sign in to comment.