Module: Locomotive::Steam::AuthService::ContentEntryAuth

Defined in:
lib/locomotive/steam/services/auth_service.rb

Overview

Module inject to the content entry to enable related authentication methods.

Instance Method Summary collapse

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/locomotive/steam/services/auth_service.rb', line 155

def valid?
  super

  name          = self[:_password_field]
  password      = self[name]
  confirmation  = self["#{name}_confirmation"]

  if password.to_s.size < Locomotive::Steam::AuthService::MIN_PASSWORD_LENGTH
    self.errors.add(name, :too_short, count: Locomotive::Steam::AuthService::MIN_PASSWORD_LENGTH)
  end

  if !password.blank? && password != confirmation
    self.errors.add("#{name}_confirmation", :confirmation, attribute: self._label_of(name))
  end

  set_password(password) if self.errors.empty?

  self.errors.empty?
end