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

fix: respect identity_relationship_user_id_attribute on Strategy.OAuth2.IdentityChange #213

Conversation

quartz55
Copy link
Contributor

Noticed this when I changed from the default user_id to e.g. account_id:

[error] Something went wrong in authentication

activity: {:oauth2, :callback}

reason: ** (Ash.Error.Invalid) Input Invalid

* argument account_id is required
  (ash 2.5.16) lib/ash/changeset/changeset.ex:860: anonymous fn/2 in Ash.Changeset.require_arguments/2
  (elixir 1.14.3) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
  (ash 2.5.16) lib/ash/changeset/changeset.ex:706: Ash.Changeset.do_for_action/4
  (ash_authentication 3.7.9) lib/ash_authentication/user_identity/actions.ex:29: AshAuthentication.UserIdentity.Actions.upsert/2
  (ash_authentication 3.7.9) lib/ash_authentication/strategies/oauth2/identity_change.ex:33: anonymous fn/3 in AshAuthentication.Strategy.OAuth2.IdentityChange.do_change/2
...

@quartz55 quartz55 changed the title Respect identity_relationship_user_id_attribute on Strategy.OAuth2.IdentityChange fix: respect identity_relationship_user_id_attribute on Strategy.OAuth2.IdentityChange Feb 25, 2023
@jimsynz
Copy link
Collaborator

jimsynz commented Feb 26, 2023

Nice catch on this bug. Can you change it so that it uses the generated functions in AshAuthentication.UserIdentity.Info rather than reaching into the strategy directly? Thanks!

@quartz55 quartz55 force-pushed the fix/respect-identity_relationship_user_id_attribute branch from 41a5992 to a682039 Compare February 26, 2023 22:58
@quartz55
Copy link
Contributor Author

Sure thing! Had to change the structure around though

@jimsynz
Copy link
Collaborator

jimsynz commented Feb 27, 2023

Thanks @quartz55. For some reason the CI is not running on this PR which is just weird. Regardless, Info.user_identity_user_id_attribute_name/1 can return :error so I'm getting a dialyzer failure because there needs to be an else clause for it.

@quartz55 quartz55 force-pushed the fix/respect-identity_relationship_user_id_attribute branch from a682039 to a311b3a Compare February 27, 2023 10:55
@quartz55
Copy link
Contributor Author

Oh right, my bad, forgot to run mix ci that time. Everything's green now 👍

@quartz55 quartz55 force-pushed the fix/respect-identity_relationship_user_id_attribute branch from a311b3a to a5231a2 Compare March 5, 2023 13:20
@jimsynz jimsynz merged commit f8d6a0d into team-alembic:main Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants