Skip to content

Azure AD: "Record does not exist" on subsequent logins #206

@pehbehbeh

Description

@pehbehbeh

We just setup Azure AD. The first login / registration works like a charm. But when we logout and login again, we get the following error:

Request: POST /auth/azure/callback
** (exit) an exception was raised:
    ** (RuntimeError) Record does not exist: %MyApp.Accounts.UserIdentity{__meta__: #Ecto.Schema.Metadata<:loaded, "user_identities">, id: "xxx-xxx-xxx-xxx-xxx", inserted_at: ~N[2021-02-12 12:49:00], provider: "azure", uid: "x-xxx-xxx", updated_at: ~N[2021-02-12 12:49:00], user: #Ecto.Association.NotLoaded<association :user is not loaded>, user_id: "xxx-xxx-xxx-xx-xxx"}
        (pow 1.0.22) lib/pow/ecto/context.ex:219: Pow.Ecto.Context.reload_after_write/2
        (pow_assent 0.4.10) lib/pow_assent/ecto/user_identities/context.ex:154: PowAssent.Ecto.UserIdentities.Context.upsert/3
        (pow_assent 0.4.10) lib/pow_assent/plug.ex:315: PowAssent.Plug.upsert_identity/2
        (pow_assent 0.4.10) lib/pow_assent/plug.ex:149: PowAssent.Plug.maybe_upsert_user_identity/1
        (pow_assent 0.4.10) lib/pow_assent/plug.ex:100: PowAssent.Plug.callback_upsert/4
        (pow 1.0.22) lib/pow/phoenix/controllers/controller.ex:77: Pow.Phoenix.Controller.action/3
        (pow_assent 0.4.10) lib/pow_assent/phoenix/controllers/authorization_controller.ex:1: PowAssent.Phoenix.AuthorizationController.action/2
        (pow_assent 0.4.10) lib/pow_assent/phoenix/controllers/authorization_controller.ex:1: PowAssent.Phoenix.AuthorizationController.phoenix_controller_pipeline/2

The record for the user_identity (and the user) definitely exists in the database. Do you have any idea how to solve this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions