The error "mail has already been made" appears twice during registration using the security extension for development (RoR)

I use a program with a security extension to check for strong passwords.

When I try to register an account with an email already received, I get the error message "email has already been received" twice in the error hash.

My user model is as follows:

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable,
  # :lockable, :timeoutable and :omniauthable
  # :trackable deleted
  devise :database_authenticatable, :registerable, :secure_validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :firstname, :lastname, :password, :password_confirmation, :remember_me
end

Without a security extension ( :validatableinstead :secure_validatable), I get an error only once.

What am I doing wrong?


PS Bonus question:

How to prevent the appearance of certain errors in the first place? Should I manipulate the RegistrationsController device or is there an option for this?

+5
source share
3

, , , devise_security_extension .

, . , .

, , .

, . , .

module Devise
  module Models
    module SecureValidatable
      module ClassMethods
        private

        def has_uniqueness_validation_of_login?
          return true if login_attribute == :email
          super
        end
      end
    end
  end
end
+1

You probably also have: validatable module active. If you mentioned this in the development settings: secure_validatable will skip these basic checks (email: availability, uniqueness and password: presence), and it only shows an error once.

devise: database_authenticatable ,: registerable ,: secure_validatable ,: validatable

0
source

All Articles