ruby on rails - Storing unconfirmed email column on the sign up -


I am using Devise with the confirmation module enabled.

I realized that the unconfirmed email column is only used when the user already has a confirmed email and has to change it.

I have the following problem:

  • User "A" signed with an email that is related to the user "B" "Never get success in verifying your account. After that, the user "B" tries to sign up with his / her own email (the first user "A" was already used). User "B" can not sign up because your email is being used by anyone else.

    I think the sign-up page should save the email from the unconfirmed email column

    This is behavior from above.

    Very interesting question I think is the easiest way to prevent this problem (but it is not certain that this is the best way) only to change email specificity verification and only if it is email only Have to work.

    To do this, you should reject the valid module in your user model and apply the assumptions manually.

    You can copy all the default assumptions from here, but validates_uniqueness_of then apply your email specification verification:

      class users & lt ; ActiveRecord :: Base # Not included: Validate modules are ready here: Confirmable: database_authenticatable, registerable, ... # Your own validations ... validates_uniqueness_of: email, allow_blank: true, if: lambda {| U | U.email_changed? & Amp; & Amp; U.confirmed? } ...   

    Edit :

    My solution is not correct First of all, email can not be confirmed if it is still Has changed. Even if my solution will work and allow the user to register with the existing unconfirmed email, when the user tries to confirm his email, he will fail.

    The correct solution is:

    1) If the email exists and is confirmed then add verification to stop registration.

    2) #confirme! Redefine .

    3) (no neÑ? Essary) To delete all other unconfirmed accounts with this email, redefine the #after_confirmation method

     < Code> class user & lt; ActiveRecord :: Base # Not included: Validate modules are to be created here: Confirmable ,: Database_Author,: # Registerable, # Validate: Confirmation email_translation radius: with_confirmed_email, - & gt; {Where.not (confirmed_at: zero)} Scope: with_unconfirmed_email, - & gt; {Where (confirmed: zero)} Confirm def! If confirmed, is the confirmation wrong? # Or the verification is added to the error or some exception is super-end private def email_changed if confirmed. Anonymous errors.add (email, "already exists")? & Amp; & Amp; Confirmed_email_exists? End DEF confirmed_email_exists? User.with_confirmed_email.where (email: self.email) .exists? End Protected DEF after_confirmation User.with_unconfirmed_email.where (email: self.email) .destroy_all super end ...    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -