mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
bd1a3bb6d7
* i18n of compliance problems * fix: return iam member roles * remove u2f/passwordless * u2f/passwordless * fix rest path GetMachineKeyByIDs * fix rest path GetMachineKeyByIDs * fix email mime-type * fix: member preferred login name * machine users in notify * fix api key query * fix: todos grpc api * fix: handle user init state * fix: tests Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
90 lines
3.0 KiB
Go
90 lines
3.0 KiB
Go
package member
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/api/grpc/object"
|
|
"github.com/caos/zitadel/internal/domain"
|
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
|
member_pb "github.com/caos/zitadel/pkg/grpc/member"
|
|
)
|
|
|
|
func ProjectGrantMembersToPb(members []*proj_model.ProjectGrantMemberView) []*member_pb.Member {
|
|
m := make([]*member_pb.Member, len(members))
|
|
for i, member := range members {
|
|
m[i] = ProjectGrantMemberToPb(member)
|
|
}
|
|
return m
|
|
}
|
|
|
|
func ProjectGrantMemberToPb(m *proj_model.ProjectGrantMemberView) *member_pb.Member {
|
|
return &member_pb.Member{
|
|
UserId: m.UserID,
|
|
Roles: m.Roles,
|
|
PreferredLoginName: m.PreferredLoginName,
|
|
Email: m.Email,
|
|
FirstName: m.FirstName,
|
|
LastName: m.LastName,
|
|
DisplayName: m.DisplayName,
|
|
Details: object.ToViewDetailsPb(
|
|
m.Sequence,
|
|
m.CreationDate,
|
|
m.ChangeDate,
|
|
"", //TODO: not returnd
|
|
),
|
|
}
|
|
}
|
|
|
|
func MemberQueriesToProjectGrantMember(queries []*member_pb.SearchQuery) []*proj_model.ProjectGrantMemberSearchQuery {
|
|
q := make([]*proj_model.ProjectGrantMemberSearchQuery, len(queries))
|
|
for i, query := range queries {
|
|
q[i] = MemberQueryToProjectGrantMember(query)
|
|
}
|
|
return q
|
|
}
|
|
|
|
func MemberQueryToProjectGrantMember(query *member_pb.SearchQuery) *proj_model.ProjectGrantMemberSearchQuery {
|
|
switch q := query.Query.(type) {
|
|
case *member_pb.SearchQuery_EmailQuery:
|
|
return EmailQueryToProjectGrantMemberQuery(q.EmailQuery)
|
|
case *member_pb.SearchQuery_FirstNameQuery:
|
|
return FirstNameQueryToProjectGrantMemberQuery(q.FirstNameQuery)
|
|
case *member_pb.SearchQuery_LastNameQuery:
|
|
return LastNameQueryToProjectGrantMemberQuery(q.LastNameQuery)
|
|
case *member_pb.SearchQuery_UserIdQuery:
|
|
return UserIDQueryToProjectGrantMemberQuery(q.UserIdQuery)
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
|
|
func FirstNameQueryToProjectGrantMemberQuery(query *member_pb.FirstNameQuery) *proj_model.ProjectGrantMemberSearchQuery {
|
|
return &proj_model.ProjectGrantMemberSearchQuery{
|
|
Key: proj_model.ProjectGrantMemberSearchKeyFirstName,
|
|
Method: object.TextMethodToModel(query.Method),
|
|
Value: query.FirstName,
|
|
}
|
|
}
|
|
|
|
func LastNameQueryToProjectGrantMemberQuery(query *member_pb.LastNameQuery) *proj_model.ProjectGrantMemberSearchQuery {
|
|
return &proj_model.ProjectGrantMemberSearchQuery{
|
|
Key: proj_model.ProjectGrantMemberSearchKeyLastName,
|
|
Method: object.TextMethodToModel(query.Method),
|
|
Value: query.LastName,
|
|
}
|
|
}
|
|
|
|
func EmailQueryToProjectGrantMemberQuery(query *member_pb.EmailQuery) *proj_model.ProjectGrantMemberSearchQuery {
|
|
return &proj_model.ProjectGrantMemberSearchQuery{
|
|
Key: proj_model.ProjectGrantMemberSearchKeyEmail,
|
|
Method: object.TextMethodToModel(query.Method),
|
|
Value: query.Email,
|
|
}
|
|
}
|
|
|
|
func UserIDQueryToProjectGrantMemberQuery(query *member_pb.UserIDQuery) *proj_model.ProjectGrantMemberSearchQuery {
|
|
return &proj_model.ProjectGrantMemberSearchQuery{
|
|
Key: proj_model.ProjectGrantMemberSearchKeyUserID,
|
|
Method: domain.SearchMethodEquals,
|
|
Value: query.UserId,
|
|
}
|
|
}
|