Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Fix sign in with multiple fields #60

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Mar 8, 2020

  1. Add failing test for sign in with multiple attrs

    The recommended implementation for sign in
    by email or username throws an error when looking up the User record.
    
    Stack trace:
    ```
      1) User signs in with username or password
         Failure/Error: params.to_h
    
         TypeError:
           wrong element type String at 0 (expected array)
         # ./lib/monban/param_transformer.rb:25:in `to_h'
         # ./lib/monban/param_transformer.rb:25:in `sanitized_params'
         # ./lib/monban/param_transformer.rb:15:in `to_h'
         # ./lib/monban.rb:66:in `transform_params'
         # ./lib/monban/configuration.rb:57:in `block in default_find_method'
         # ./lib/monban.rb:90:in `lookup'
         # ./lib/monban/controller_helpers.rb:105:in `authenticate_session'
         # ./spec/rails_app/app/controllers/multiple_attributes_sessions_controller.rb:6:in `create'
         # ./lib/monban/back_door.rb:30:in `call'
         # ./spec/features/user/user_signs_in_spec.rb:25:in `block (2 levels) in <top (required)>'
    ```
    c-lliope authored and JuanitoFatas committed Mar 8, 2020
    Configuration menu
    Copy the full SHA
    b728e1f View commit details
    Browse the repository at this point in the history
  2. Fix multiple attribute lookup bug

    This fix potentially skips over parameter sanitization.
    If it does, the error seems to not be covered by any test cases.
    c-lliope authored and JuanitoFatas committed Mar 8, 2020
    Configuration menu
    Copy the full SHA
    7cd037f View commit details
    Browse the repository at this point in the history
  3. Fix typo in spec

    c-lliope authored and JuanitoFatas committed Mar 8, 2020
    Configuration menu
    Copy the full SHA
    567c1ee View commit details
    Browse the repository at this point in the history
  4. Fix sign in with multiple fields spec

    The ActiveHash does not support pass in array
    of query strings:
    
    User.where(["email = ? OR username = ?", "example", "example"])
    
    Mimic the real behavior in test instead.
    JuanitoFatas committed Mar 8, 2020
    Configuration menu
    Copy the full SHA
    d4ede24 View commit details
    Browse the repository at this point in the history