Use Verification::Email.valid_token? instead of .find

This way it's more obvious that the method is supposed to return a
boolean. When upgrading rubocop, we get a `Naming/PredicateMethod` error
due to `.find` returning a boolean.
This commit is contained in:
Javi Martín
2025-10-31 14:56:57 +01:00
parent 520f0c42d4
commit 2fdfefe55d
2 changed files with 1 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ class Verification::EmailController < ApplicationController
skip_authorization_check skip_authorization_check
def show def show
if Verification::Email.find(current_user, params[:email_verification_token]) if Verification::Email.valid_token?(current_user, params[:email_verification_token])
current_user.update!(verified_at: Time.current) current_user.update!(verified_at: Time.current)
redirect_to account_path, notice: t("verification.email.show.flash.success") redirect_to account_path, notice: t("verification.email.show.flash.success")
else else

View File

@@ -26,10 +26,6 @@ class Verification::Email
@plain_token, @encrypted_token = Devise.token_generator.generate(User, :email_verification_token) @plain_token, @encrypted_token = Devise.token_generator.generate(User, :email_verification_token)
end end
def self.find(user, token)
valid_token?(user, token)
end
def self.valid_token?(user, token) def self.valid_token?(user, token)
Devise.token_generator.digest(User, :email_verification_token, user.email_verification_token) == token Devise.token_generator.digest(User, :email_verification_token, user.email_verification_token) == token
end end