memos/api/v2/auth_service.go

21 lines
528 B
Go
Raw Normal View History

2023-11-30 20:58:36 +08:00
package v2
import (
"context"
2023-11-30 21:52:02 +08:00
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
2023-11-30 20:58:36 +08:00
apiv2pb "github.com/usememos/memos/proto/gen/api/v2"
)
func (s *APIV2Service) GetAuthStatus(ctx context.Context, _ *apiv2pb.GetAuthStatusRequest) (*apiv2pb.GetAuthStatusResponse, error) {
user, err := getCurrentUser(ctx, s.Store)
2023-11-30 21:52:02 +08:00
if err != nil {
return nil, status.Errorf(codes.Unauthenticated, "failed to get current user: %v", err)
2023-11-30 20:58:36 +08:00
}
return &apiv2pb.GetAuthStatusResponse{
2023-11-30 21:52:02 +08:00
User: convertUserFromStore(user),
2023-11-30 20:58:36 +08:00
}, nil
}