Created
June 20, 2016 05:13
-
-
Save denvazh/f029c3d83c2505ab53294e7fa133670f to your computer and use it in GitHub Desktop.
Use email instead of confirmation token in Devise model (mainly used during stress testing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unless Rails.env.test? | |
module Devise | |
module Models | |
module Confirmable | |
module ClassMethods | |
# Use email instead of confirmation_token, i.e. if user exist it will be confirmed | |
def confirm_by_token(email) | |
user_confirmable = find_first_by_auth_conditions(email: email) | |
unless user_confirmable | |
user_confirmable = find_or_initialize_with_error_by(:email, email) | |
end | |
user_confirmable.confirm if user_confirmable.persisted? | |
user_confirmable | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment