MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetCurrentUser

Method GetCurrentUser

backend/api/v1/user_service.go:121–131  ·  view source on GitHub ↗

GetCurrentUser gets the current authenticated user.

(ctx context.Context, _ *connect.Request[emptypb.Empty])

Source from the content-addressed store, hash-verified

119
120// GetCurrentUser gets the current authenticated user.
121func (s *UserService) GetCurrentUser(ctx context.Context, _ *connect.Request[emptypb.Empty]) (*connect.Response[v1pb.User], error) {
122 user, ok := GetUserFromContext(ctx)
123 if !ok || user == nil {
124 return nil, connect.NewError(connect.CodeUnauthenticated, errors.Errorf("authenticated user not found"))
125 }
126 v1User, err := convertToUser(ctx, s.iamManager, user)
127 if err != nil {
128 return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to convert user"))
129 }
130 return connect.NewResponse(v1User), nil
131}
132
133// ListUsers lists all users.
134func (s *UserService) ListUsers(ctx context.Context, request *connect.Request[v1pb.ListUsersRequest]) (*connect.Response[v1pb.ListUsersResponse], error) {

Callers

nothing calls this directly

Calls 3

GetUserFromContextFunction · 0.85
convertToUserFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected