mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:17:32 +00:00
fix: move activity log to queries and remove old code (#3096)
* move changes to queries and remove old code * fix changes query * remove unused code * fix sorting * fix sorting * refactor and remove old code * remove accidental go.mod replace * add missing file * remove listDetail from ChangesResponse
This commit is contained in:
@@ -1,21 +1,33 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/zitadel/internal/api/authz"
|
||||
"github.com/caos/zitadel/internal/api/grpc/object"
|
||||
"github.com/caos/zitadel/internal/usergrant/model"
|
||||
"github.com/caos/zitadel/internal/query"
|
||||
auth_pb "github.com/caos/zitadel/pkg/grpc/auth"
|
||||
)
|
||||
|
||||
func ListMyUserGrantsRequestToModel(req *auth_pb.ListMyUserGrantsRequest) *model.UserGrantSearchRequest {
|
||||
func ListMyUserGrantsRequestToQuery(ctx context.Context, req *auth_pb.ListMyUserGrantsRequest) (*query.UserGrantsQueries, error) {
|
||||
offset, limit, asc := object.ListQueryToModel(req.Query)
|
||||
return &model.UserGrantSearchRequest{
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
Asc: asc,
|
||||
userGrantUserID, err := query.NewUserGrantUserIDSearchQuery(authz.GetCtxData(ctx).UserID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &query.UserGrantsQueries{
|
||||
SearchRequest: query.SearchRequest{
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
Asc: asc,
|
||||
},
|
||||
Queries: []query.SearchQuery{
|
||||
userGrantUserID,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func UserGrantsToPb(grants []*model.UserGrantView) []*auth_pb.UserGrant {
|
||||
func UserGrantsToPb(grants []*query.UserGrant) []*auth_pb.UserGrant {
|
||||
userGrants := make([]*auth_pb.UserGrant, len(grants))
|
||||
for i, grant := range grants {
|
||||
userGrants[i] = UserGrantToPb(grant)
|
||||
@@ -23,13 +35,13 @@ func UserGrantsToPb(grants []*model.UserGrantView) []*auth_pb.UserGrant {
|
||||
return userGrants
|
||||
}
|
||||
|
||||
func UserGrantToPb(grant *model.UserGrantView) *auth_pb.UserGrant {
|
||||
func UserGrantToPb(grant *query.UserGrant) *auth_pb.UserGrant {
|
||||
return &auth_pb.UserGrant{
|
||||
GrantId: grant.ID,
|
||||
OrgId: grant.ResourceOwner,
|
||||
OrgName: grant.OrgName,
|
||||
ProjectId: grant.ProjectID,
|
||||
UserId: grant.UserID,
|
||||
Roles: grant.RoleKeys,
|
||||
Roles: grant.Roles,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user