Skip to content

Commit

Permalink
simplify otp_set_flash_message method via existing Devise set_flash_m…
Browse files Browse the repository at this point in the history
…essage functionality;
  • Loading branch information
strouptl committed Sep 20, 2024
1 parent 04d51c6 commit 4e16540
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions lib/devise_otp_authenticatable/controllers/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,8 @@ def authenticate_scope!
#
def otp_set_flash_message(key, kind, options = {})
options[:scope] ||= "devise.otp.#{controller_name}"
options[:default] = Array(options[:default]).unshift(kind.to_sym)
options[:resource_name] = resource_name
options = devise_i18n_options(options) if respond_to?(:devise_i18n_options, true)
message = I18n.t("#{options[:resource_name]}.#{kind}", **options)

if message.present?
if options[:now]
flash.now[key] = message
else
flash[key] = message
end
end

set_flash_message(key, kind, options)
end

def otp_t
Expand Down

0 comments on commit 4e16540

Please sign in to comment.