fix(auth): harden oauth callback adoption flows
This commit is contained in:
@@ -551,7 +551,7 @@ func (h *AuthHandler) CompleteWeChatOAuthRegistration(c *gin.Context) {
|
||||
response.ErrorFrom(c, err)
|
||||
return
|
||||
}
|
||||
decision, err := h.upsertPendingOAuthAdoptionDecision(c, session.ID, oauthAdoptionDecisionRequest{
|
||||
decision, err := h.ensurePendingOAuthAdoptionDecision(c, session.ID, oauthAdoptionDecisionRequest{
|
||||
AdoptDisplayName: req.AdoptDisplayName,
|
||||
AdoptAvatar: req.AdoptAvatar,
|
||||
})
|
||||
@@ -827,7 +827,10 @@ func (h *AuthHandler) findWeChatUserByLegacyOpenID(
|
||||
return nil, infraerrors.InternalServer("AUTH_IDENTITY_LOOKUP_FAILED", "failed to inspect auth identity ownership").WithCause(err)
|
||||
}
|
||||
if user, err := singleWeChatIdentityUser(records); err != nil || user != nil {
|
||||
return user, err
|
||||
if err != nil || user == nil {
|
||||
return user, err
|
||||
}
|
||||
return findActiveUserByID(ctx, client, user.ID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -851,7 +854,10 @@ func (h *AuthHandler) findWeChatUserByLegacyOpenID(
|
||||
return nil, infraerrors.InternalServer("AUTH_IDENTITY_CHANNEL_LOOKUP_FAILED", "failed to inspect auth identity channel ownership").WithCause(err)
|
||||
}
|
||||
if user, err := singleWeChatChannelUser(records); err != nil || user != nil {
|
||||
return user, err
|
||||
if err != nil || user == nil {
|
||||
return user, err
|
||||
}
|
||||
return findActiveUserByID(ctx, client, user.ID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -870,7 +876,11 @@ func (h *AuthHandler) findWeChatUserByLegacyOpenID(
|
||||
if err != nil {
|
||||
return nil, infraerrors.InternalServer("AUTH_IDENTITY_LOOKUP_FAILED", "failed to inspect auth identity ownership").WithCause(err)
|
||||
}
|
||||
return singleWeChatIdentityUser(records)
|
||||
user, err := singleWeChatIdentityUser(records)
|
||||
if err != nil || user == nil {
|
||||
return user, err
|
||||
}
|
||||
return findActiveUserByID(ctx, client, user.ID)
|
||||
}
|
||||
|
||||
func wechatCompatibleProviderKeys(providerKey string) []string {
|
||||
|
||||
Reference in New Issue
Block a user