Devise - How to Change Setting So That Email Addresses Don't Need to Be Unique

Devise - how to change setting so that email addresses don't need to be unique

Look in the config/initializers/devise.rb. You can change the default authentication key, which by default is :email to be anything you want, for example:

config.authentication_keys = [ :username ]

Don't allow a user to change email address using devise with Rails

In my case, the "answer" was to simply allow people to edit their email addresses. There are enough use cases in which somebody could legitimately want to change their email address that I figured there was no harm in trying to stop it.

Configuring Devise to treat email addresses case-insensitively in all circumstances?

If you can't update your external scripts to downcase email addresses, you could always add a trigger to the table in the database to do it for all inserts/updates:

CREATE FUNCTION user_upsert() RETURNS trigger AS $user_upsert$
BEGIN
NEW.email_address := LOWER(NEW.email_address);
RETURN NEW;
END;
$user_upsert$ LANGUAGE plpgsql;

CREATE TRIGGER user_upsert BEFORE INSERT OR UPDATE ON user
FOR EACH ROW EXECUTE PROCEDURE user_upsert();

How to change email address of a user in devise safely ?

You can force the user to confirm his account again if he changes his email.

Once, you updated the password of the concerned user, you need to un-confirm the user, and then re-send the confirmation email.

To unconfirm the user :

user = User.find(1)
if user.confirmed?
user.confirmed_at = nil
user.save(:validate => false)
end

To resend the email confirmation :

user = User.find(1)
user.send_confirmation_instructions

Hope this help !

Does devise support multiple accounts with the same email?

Set

config.authentication_keys = [ :username ]

in your device.rb. You may also use the following settings to make login more solid

config.case_insensitive_keys = [ :username ]
config.strip_whitespace_keys = [ :username ]

rails 3 + devise: how to modify the mailer method for confirmation emails to add user's second email address

One way to do it would be to override the headers_for action in Devise::Mailer

class MyMailer < Devise::Mailer
backup_email = "..."
def headers_for(action)
headers = {
:subject => translate(devise_mapping, action),
:from => mailer_sender(devise_mapping),
:to => resource.email,
:bcc => backup_email
:template_path => template_paths
}
end

And tell devise to use your mailer:

#config/initializers/devise.rb
config.mailer = "MyMailer"

How to specify Devise 'from' email

config.mailer_sender property in config/devise/devise.rb allows you to specify that. If you don't have config/devise/devise.rb, run devise:install generator.



Related Topics



Leave a reply



Submit