zitadel/internal/api/grpc/auth/profile.go
Livio Amstutz e9eb5b7848
fix: converters (#1413)
* fix: converters

* fix: converters

* comments
2021-03-12 14:06:05 +01:00

40 lines
1.0 KiB
Go

package auth
import (
"context"
object_grpc "github.com/caos/zitadel/internal/api/grpc/object"
user_grpc "github.com/caos/zitadel/internal/api/grpc/user"
auth_pb "github.com/caos/zitadel/pkg/grpc/auth"
)
func (s *Server) GetMyProfile(ctx context.Context, req *auth_pb.GetMyProfileRequest) (*auth_pb.GetMyProfileResponse, error) {
profile, err := s.repo.MyProfile(ctx)
if err != nil {
return nil, err
}
return &auth_pb.GetMyProfileResponse{
Profile: user_grpc.ProfileToPb(profile),
Details: object_grpc.ToViewDetailsPb(
profile.Sequence,
profile.CreationDate,
profile.ChangeDate,
profile.ResourceOwner,
),
}, nil
}
func (s *Server) UpdateMyProfile(ctx context.Context, req *auth_pb.UpdateMyProfileRequest) (*auth_pb.UpdateMyProfileResponse, error) {
profile, err := s.command.ChangeHumanProfile(ctx, UpdateProfileToDomain(ctx, req))
if err != nil {
return nil, err
}
return &auth_pb.UpdateMyProfileResponse{
Details: object_grpc.ToDetailsPb(
profile.Sequence,
profile.ChangeDate,
profile.ResourceOwner,
),
}, nil
}