Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing "no case clause matching" when use with GuardianDB #242

Closed
yuchunc opened this issue Dec 25, 2016 · 15 comments
Closed

Throwing "no case clause matching" when use with GuardianDB #242

yuchunc opened this issue Dec 25, 2016 · 15 comments
Labels

Comments

@yuchunc
Copy link
Contributor

yuchunc commented Dec 25, 2016

Hi, I upgraded the to the latest Guardian package, and ran in to this exception:

** (exit) an exception was raised:
    ** (CaseClauseError) no case clause matching: {:ok, {%ElixirTw.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">, crypted_password: nil, email: "poverwhelming@gmail.com", id: 1, inserted_at: #Ecto.DateTime<2016-10-01 14:38:47>, name: "Mickey Chen", oauth_infos: #Ecto.Association.NotLoaded<association :oauth_infos is not loaded>, posts: #Ecto.Association.NotLoaded<association :posts is not loaded>, updated_at: #Ecto.DateTime<2016-10-01 14:38:47>}, nil, %{"aud" => "User:1", "exp" => 1485240250, "iat" => 1482648250, "iss" => "ElixirTW", "jti" => "ea6a199e-4e52-4472-96f9-e84ef0ad4dc1", "pem" => %{}, "sub" => "User:1", "typ" => "access"}, "eyJhbGciOiJFUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJVc2VyOjEiLCJleHAiOjE0ODUyNDAyNTAsImlhdCI6MTQ4MjY0ODI1MCwiaXNzIjoiRWxpeGlyVFciLCJqdGkiOiJlYTZhMTk5ZS00ZTUyLTQ0NzItOTZmOS1lODRlZjBhZDRkYzEiLCJwZW0iOnt9LCJzdWIiOiJVc2VyOjEiLCJ0eXAiOiJhY2Nlc3MifQ.AZUR4vzOGuYFEW3z1vvms4VZjPGR6EC4XBjL0Hvmax3CSiU_uyLe7CIpUvXpybmo59MTZZN0ouOFvuaznPuQhDcAAMuUVRWgMjQmJRmJUzr0uEbvm3H-JBVZs0tp-FbtT8rLfC2ZuxAvob8G5v8GPpIObWlUO8LOiUaBD0aw2oWudyiq"}}
        (guardian) lib/guardian.ex:100: Guardian.encode_from_hooked/1
        (guardian) lib/guardian/plug.ex:117: Guardian.Plug.sign_in/4
        (elixir_tw) web/controllers/session_controller.ex:51: ElixirTw.SessionController.callback/2
        (elixir_tw) web/controllers/session_controller.ex:1: ElixirTw.SessionController.action/2
        (elixir_tw) web/controllers/session_controller.ex:1: ElixirTw.SessionController.phoenix_controller_pipeline/2
        (elixir_tw) lib/elixir_tw/endpoint.ex:1: ElixirTw.Endpoint.instrument/4
        (elixir_tw) lib/phoenix/router.ex:261: ElixirTw.Router.dispatch/2
        (elixir_tw) web/router.ex:1: ElixirTw.Router.do_call/2
        (elixir_tw) lib/elixir_tw/endpoint.ex:1: ElixirTw.Endpoint.phoenix_pipeline/1
        (elixir_tw) lib/plug/debugger.ex:123: ElixirTw.Endpoint."call (overridable 3)"/2
        (elixir_tw) lib/elixir_tw/endpoint.ex:1: ElixirTw.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

after some digging into the code I think it's a miss match between:

GuardianDb's [after_encode_and_sign] (https://github.com/hassox/guardian_db/blob/master/lib/guardian_db.ex#L77)

and

Guardian's https://github.com/ueberauth/guardian/blob/master/lib/guardian.ex#L105

If we just tweak the pattern a little bit to {:ok, _} it would resolve the issue.

yuchunc added a commit to yuchunc/guardian that referenced this issue Dec 25, 2016
Module Guardian line 105, changed `:ok` to `{:ok, _}` ueberauth#242
@yuchunc
Copy link
Contributor Author

yuchunc commented Dec 25, 2016

Apologies if I didn't do the pull request right, I am not familiar to the proper way of contributing to a project.
Please let me know if I'm missing anything, I will patch it.

@doomspork
Copy link
Member

Thanks for the report @yuchunc 👍 I'll take a peek at your PR today.

@jamesvl
Copy link

jamesvl commented Dec 30, 2016

Yep, I'm getting the same thing. Applying PR #243 fixed it locally. (Until it's merged I can't use it in my CI system, of course.)

doomspork pushed a commit that referenced this issue Jan 2, 2017
* fix pattern miss match when use with GuardianDB

Module Guardian line 105, changed `:ok` to `{:ok, _}` #242

* fix Guardian.Hooks.Test's after_encode_and_sign output
@jamesvl
Copy link

jamesvl commented Jan 3, 2017

Any idea on when you'll cut a new release for hex.pm? This will remain broken for anyone until then.

@doomspork
Copy link
Member

@jamesvl I intend to cut a new release today but in the meantime you can use master:

{:guardian, github: "ueberauth/guardian"}

@doomspork
Copy link
Member

0.14.1 has been released.

@collegeimprovements
Copy link

Hi, I got this error even after the upgrade. I got the same error with 0.14.1.

@larryweya
Copy link

Same issue as @collegeimprovements after upgrade to 0.14.1. Found the issue and opened a pull request #250

@doomspork
Copy link
Member

@larryweya / @collegeimprovements / @NilsLattek — a fix has been merged into master, before I cut a new release could one of you please verify that master is working for you? I'm currently traveling and don't have everything I need to smoke test it.

@Ch4s3
Copy link

Ch4s3 commented Jan 5, 2017

@doomspork I was having the same problem and using {:guardian, github: "ueberauth/guardian"} fixes it for me.

Is this the fix?

@larryweya
Copy link

@doomspork works for me too.

@doomspork
Copy link
Member

Thank you @Ch4s3 and @larryweya 👍

@doomspork
Copy link
Member

I've released 0.14.2, hopefully this resolves everyone's issues. The ueberauth org is taking over GuardianDB maintenance so I'll be putting some time into clean-up in the coming weeks.

@jacktang
Copy link

jacktang commented Jan 7, 2017

I am facing the same problem and 0.14.2 works fine

@Ch4s3
Copy link

Ch4s3 commented Jan 7, 2017

Can confirm, 0.14.2 works

Hanspagh pushed a commit to Hanspagh/guardian that referenced this issue Nov 1, 2017
* fix pattern miss match when use with GuardianDB

Module Guardian line 105, changed `:ok` to `{:ok, _}` ueberauth#242

* fix Guardian.Hooks.Test's after_encode_and_sign output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants