mirror of
https://github.com/zitadel/zitadel.git
synced 2025-10-27 12:08:56 +00:00
feat: api v2beta to api v2 (#8283)
# Which Problems Are Solved
The v2beta services are stable but not GA.
# How the Problems Are Solved
The v2beta services are copied to v2. The corresponding v1 and v2beta
services are deprecated.
# Additional Context
Closes #7236
---------
Co-authored-by: Elio Bischof <elio@zitadel.com>
(cherry picked from commit 7d2d85f57c)
This commit is contained in:
committed by
Livio Spring
parent
40c348a75e
commit
ce29a78d1b
@@ -98,6 +98,29 @@ type AuthMethods struct {
|
||||
AuthMethods []*AuthMethod
|
||||
}
|
||||
|
||||
func (l *AuthMethods) RemoveNoPermission(ctx context.Context, permissionCheck domain.PermissionCheck) {
|
||||
removableIndexes := make([]int, 0)
|
||||
for i := range l.AuthMethods {
|
||||
ctxData := authz.GetCtxData(ctx)
|
||||
if ctxData.UserID != l.AuthMethods[i].UserID {
|
||||
if err := permissionCheck(ctx, domain.PermissionUserRead, l.AuthMethods[i].ResourceOwner, l.AuthMethods[i].UserID); err != nil {
|
||||
removableIndexes = append(removableIndexes, i)
|
||||
}
|
||||
}
|
||||
}
|
||||
removed := 0
|
||||
for _, removeIndex := range removableIndexes {
|
||||
l.AuthMethods = removeAuthMethod(l.AuthMethods, removeIndex-removed)
|
||||
removed++
|
||||
}
|
||||
// reset count as some users could be removed
|
||||
l.SearchResponse.Count = uint64(len(l.AuthMethods))
|
||||
}
|
||||
|
||||
func removeAuthMethod(slice []*AuthMethod, s int) []*AuthMethod {
|
||||
return append(slice[:s], slice[s+1:]...)
|
||||
}
|
||||
|
||||
type AuthMethod struct {
|
||||
UserID string
|
||||
CreationDate time.Time
|
||||
|
||||
Reference in New Issue
Block a user