From d867fa1a63c53245525c21f7ce371dffbcbebf5e Mon Sep 17 00:00:00 2001 From: James Elliott Date: Wed, 2 Mar 2022 16:33:47 +1100 Subject: [PATCH] fix(storage): return reason for identity verification not being found (#2937) This includes the reason a token was not found during the identity verification process. --- internal/storage/sql_provider.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/storage/sql_provider.go b/internal/storage/sql_provider.go index dfbf43de..42673d2b 100644 --- a/internal/storage/sql_provider.go +++ b/internal/storage/sql_provider.go @@ -255,8 +255,10 @@ func (p *SQLProvider) FindIdentityVerification(ctx context.Context, jti string) } switch { - case verification.Consumed != nil, verification.ExpiresAt.Before(time.Now()): - return false, nil + case verification.Consumed != nil: + return false, fmt.Errorf("the token has already been consumed") + case verification.ExpiresAt.Before(time.Now()): + return false, fmt.Errorf("the token expired %s ago", time.Since(verification.ExpiresAt)) default: return true, nil }