Skip to content

Commit

Permalink
Handle gracefully missing :scope in params (#193)
Browse files Browse the repository at this point in the history
When params do not include the required scope key (e.g. user)
then TwoFactorAuthenticatable throws exception "undefined method :[] for nil:NilClass".
This change is to handle such scenario gracefully
  • Loading branch information
sgomez17 committed Aug 22, 2023
1 parent 11e60a7 commit d486aed
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -21,7 +21,7 @@ def authenticate!

def validate_otp(resource)
return true unless resource.otp_required_for_login
return if params[scope]['otp_attempt'].nil?
return if params[scope].nil? || params[scope]['otp_attempt'].nil?
resource.validate_and_consume_otp!(params[scope]['otp_attempt'])
end
end
Expand Down

0 comments on commit d486aed

Please sign in to comment.