Skip to content
Snippets Groups Projects
Verified Commit a73d02c0 authored by Andrej Shadura's avatar Andrej Shadura
Browse files

Unbreak the validators


Backports of upstream commits 5524ffcc and 362bdc3a moved some validation
code into a validate method which was never called. A simple fix makes
this code run again.

Signed-off-by: Andrej Shadura's avatarAndrej Shadura <andrew.shadura@collabora.co.uk>
parent 4c84d221
No related branches found
No related tags found
1 merge request!21OBS SSO implementation
......@@ -358,7 +358,7 @@ class User < ActiveRecord::Base
# Overriding this method to do some more validation: Password equals
# password_confirmation, state an password hash type being in the range
# of allowed values.
def validate
validate do
# validate state and password has type to be in the valid range of values
errors.add(:password_hash_type, 'must be in the list of hash types.') unless password_hash_type.in?(PASSWORD_HASH_TYPES)
# check that the state transition is valid
......@@ -371,10 +371,10 @@ class User < ActiveRecord::Base
# check that the password hash type has not been set if no new password
# has been provided
return unless password_hash_type_changed? && (!password_changed? || password_was.nil?)
if password_hash_type_changed? && (!password_changed? || password_was.nil?)
errors.add(:password_hash_type, 'cannot be changed unless a new password has been provided.')
end
end
validates :login, :password, :password_hash_type, :state,
presence: { message: 'must be given' }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment