From 67b429084638aba1627ade801997b90a9a9bac61 Mon Sep 17 00:00:00 2001 From: Ankit Nayan Date: Wed, 4 May 2022 17:33:54 +0530 Subject: [PATCH] chore: change in error message on register (#1068) --- pkg/query-service/auth/auth.go | 6 +++++- pkg/query-service/auth/utils.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/query-service/auth/auth.go b/pkg/query-service/auth/auth.go index 9c958ff7e8..1a5775334a 100644 --- a/pkg/query-service/auth/auth.go +++ b/pkg/query-service/auth/auth.go @@ -125,7 +125,11 @@ func validateInvite(ctx context.Context, req *RegisterRequest) (*model.Invitatio return nil, errors.Wrap(err.Err, "Failed to read from DB") } - if invitation == nil || invitation.Token != req.InviteToken { + if invitation == nil { + return nil, ErrorAskAdmin + } + + if invitation.Token != req.InviteToken { return nil, ErrorInvalidInviteToken } diff --git a/pkg/query-service/auth/utils.go b/pkg/query-service/auth/utils.go index 5e13c32b8f..4de59ea2c0 100644 --- a/pkg/query-service/auth/utils.go +++ b/pkg/query-service/auth/utils.go @@ -15,6 +15,7 @@ var ( ErrorInvalidRole = errors.New("Invalid role") ErrorInvalidInviteToken = errors.New("Invalid invite token") + ErrorAskAdmin = errors.New("You are not allowed to create an account. Please ask your admin to send an invite link") ) func randomHex(sz int) (string, error) {