feat: add admin auth identity repair binding
This commit is contained in:
@@ -18,6 +18,8 @@ type stubAdminService struct {
|
||||
proxyCounts []service.ProxyWithAccountCount
|
||||
redeems []service.RedeemCode
|
||||
migrationReports []service.AuthIdentityMigrationReport
|
||||
boundAuthIdentity *service.AdminBindAuthIdentityInput
|
||||
boundAuthIdentityFor int64
|
||||
createdAccounts []*service.CreateAccountInput
|
||||
createdProxies []*service.CreateProxyInput
|
||||
updatedProxyIDs []int64
|
||||
@@ -201,6 +203,52 @@ func (s *stubAdminService) GetAuthIdentityMigrationReportSummary(ctx context.Con
|
||||
return summary, nil
|
||||
}
|
||||
|
||||
func (s *stubAdminService) BindUserAuthIdentity(ctx context.Context, userID int64, input service.AdminBindAuthIdentityInput) (*service.AdminBoundAuthIdentity, error) {
|
||||
s.boundAuthIdentityFor = userID
|
||||
copied := input
|
||||
if input.Metadata != nil {
|
||||
copied.Metadata = map[string]any{}
|
||||
for key, value := range input.Metadata {
|
||||
copied.Metadata[key] = value
|
||||
}
|
||||
}
|
||||
if input.Channel != nil {
|
||||
channel := *input.Channel
|
||||
if input.Channel.Metadata != nil {
|
||||
channel.Metadata = map[string]any{}
|
||||
for key, value := range input.Channel.Metadata {
|
||||
channel.Metadata[key] = value
|
||||
}
|
||||
}
|
||||
copied.Channel = &channel
|
||||
}
|
||||
s.boundAuthIdentity = &copied
|
||||
|
||||
now := time.Now().UTC()
|
||||
result := &service.AdminBoundAuthIdentity{
|
||||
UserID: userID,
|
||||
ProviderType: input.ProviderType,
|
||||
ProviderKey: input.ProviderKey,
|
||||
ProviderSubject: input.ProviderSubject,
|
||||
VerifiedAt: &now,
|
||||
Issuer: input.Issuer,
|
||||
Metadata: input.Metadata,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
if input.Channel != nil {
|
||||
result.Channel = &service.AdminBoundAuthIdentityChannel{
|
||||
Channel: input.Channel.Channel,
|
||||
ChannelAppID: input.Channel.ChannelAppID,
|
||||
ChannelSubject: input.Channel.ChannelSubject,
|
||||
Metadata: input.Channel.Metadata,
|
||||
CreatedAt: now,
|
||||
UpdatedAt: now,
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *stubAdminService) ListGroups(ctx context.Context, page, pageSize int, platform, status, search string, isExclusive *bool, sortBy, sortOrder string) ([]service.Group, int64, error) {
|
||||
return s.groups, int64(len(s.groups)), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user