cold-insurance-50617
03/07/2025, 2:01 PMctx.flow.request_url
to determine what oidc provider the user was attempting login with that prompted the account linking step.
my goal is to perform some internal account synchronization steps based on what oidc provider they are trying to link to their existing account.
in the context of the after login hook it doesn't seem like I have access to the oidc provider details like the after registration hook, which presents another problem as I am unable to access openid account details for the secondary account being linked.magnificent-energy-493
cold-insurance-50617
03/10/2025, 6:22 AMmagnificent-energy-493
1. The user creates an account with the identifierand a password.<mailto:alice@example.com|alice@example.com>
2. When signing in later, the user signs in with a social sign-in provider. That social sign-in account (through the OIDC userinfo endpoint or the identity token) contains the same identifier.<mailto:alice@example.com|alice@example.com>
3. Since the identifier already exists, the user can't be logged in directly. Instead, the user will be prompted to enter the password chosen in step 1.
4. After entering the correct password, the social sign-in is linked to the user's account. Now they can sign in with either password or social sign-in provider.please let me know if that is clear, or if you understand something different under "account linking"
cold-insurance-50617
03/11/2025, 10:48 AMcold-insurance-50617
03/13/2025, 2:28 PMafter login
hook and inspecting the context.flow.ui.messages
for a duplicateProvider
key and then extracting the provider
property.
I then use the users identity id
to pull their provider
subject
from the identity_credentials
table.
would love to know if there is a better way to hook into a successful account linking event and a cleaner way to access provider data used in the account linking process.
func getDuplicateProvider(payload AfterLoginWebhookPayload) string {
// Defensive check: payload or messages could be nil
if payload.Context.Flow.UI.Messages == nil {
return ""
}
var email = payload.Context.Identity.Traits.Email
for _, msg := range *payload.Context.Flow.UI.Messages {
var ctx = msg.Context
if ctx == nil || ctx.DuplicateIdentifier == nil || ctx.Provider == nil {
continue
}
if *ctx.DuplicateIdentifier == email {
return *ctx.Provider
}
}
return ""
}