Method: Devise::Models::Confirmable::ClassMethods#confirm_by_token
- Defined in:
- lib/devise/models/confirmable.rb
#confirm_by_token(confirmation_token) ⇒ Object
Find a user by its confirmation token and try to confirm it. If no user is found, returns a new user with an error. If the user is already confirmed, create an error for the user Options must have the confirmation_token
311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/devise/models/confirmable.rb', line 311 def confirm_by_token(confirmation_token) confirmable = find_first_by_auth_conditions(confirmation_token: confirmation_token) unless confirmable confirmation_digest = Devise.token_generator.digest(self, :confirmation_token, confirmation_token) confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_digest) end # TODO: replace above lines with # confirmable = find_or_initialize_with_error_by(:confirmation_token, confirmation_token) # after enough time has passed that Devise clients do not use digested tokens confirmable.confirm if confirmable.persisted? confirmable end |