2020-07-08 11:56:37 +00:00
|
|
|
package management
|
2020-03-24 09:14:39 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-05-13 12:22:29 +00:00
|
|
|
|
2020-03-24 09:14:39 +00:00
|
|
|
"github.com/golang/protobuf/ptypes/empty"
|
2020-07-08 11:56:37 +00:00
|
|
|
|
|
|
|
"github.com/caos/zitadel/pkg/grpc/management"
|
2020-03-24 09:14:39 +00:00
|
|
|
)
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) GetOrgMemberRoles(ctx context.Context, _ *empty.Empty) (*management.OrgMemberRoles, error) {
|
|
|
|
return &management.OrgMemberRoles{Roles: s.org.GetOrgMemberRoles()}, nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) SearchMyOrgMembers(ctx context.Context, in *management.OrgMemberSearchRequest) (*management.OrgMemberSearchResponse, error) {
|
2020-06-10 08:47:50 +00:00
|
|
|
members, err := s.org.SearchMyOrgMembers(ctx, orgMemberSearchRequestToModel(in))
|
2020-05-26 14:46:16 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return orgMemberSearchResponseFromModel(members), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) AddMyOrgMember(ctx context.Context, member *management.AddOrgMemberRequest) (*management.OrgMember, error) {
|
2020-06-10 08:47:50 +00:00
|
|
|
addedMember, err := s.org.AddMyOrgMember(ctx, addOrgMemberToModel(member))
|
2020-05-13 12:22:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return orgMemberFromModel(addedMember), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) ChangeMyOrgMember(ctx context.Context, member *management.ChangeOrgMemberRequest) (*management.OrgMember, error) {
|
2020-06-10 08:47:50 +00:00
|
|
|
changedMember, err := s.org.ChangeMyOrgMember(ctx, changeOrgMemberToModel(member))
|
2020-05-13 12:22:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return orgMemberFromModel(changedMember), nil
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|
|
|
|
|
2020-07-08 11:56:37 +00:00
|
|
|
func (s *Server) RemoveMyOrgMember(ctx context.Context, member *management.RemoveOrgMemberRequest) (*empty.Empty, error) {
|
2020-06-10 08:47:50 +00:00
|
|
|
err := s.org.RemoveMyOrgMember(ctx, member.UserId)
|
2020-05-13 12:22:29 +00:00
|
|
|
return &empty.Empty{}, err
|
2020-03-24 09:14:39 +00:00
|
|
|
}
|