From 9014c42c2ec8100935bb291eb825745e51393dbf Mon Sep 17 00:00:00 2001 From: Myles <96409608+ice-myles@users.noreply.github.com> Date: Thu, 22 Aug 2024 12:38:53 +0300 Subject: [PATCH] Verify sign in nil pointer dereference fix. (#212) --- auth/email_link/link_verify.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/auth/email_link/link_verify.go b/auth/email_link/link_verify.go index 3b23cf38..690f0712 100644 --- a/auth/email_link/link_verify.go +++ b/auth/email_link/link_verify.go @@ -91,8 +91,8 @@ func (c *client) verifySignIn(ctx context.Context, els *emailLinkSignIn, id *log var mErr *multierror.Error if els.ConfirmationCodeWrongAttemptsCount >= c.cfg.ConfirmationCode.MaxWrongAttemptsCount { blockEndTime := time.Now().Add(c.cfg.EmailValidation.BlockDuration) - blockTimeFitsNow := (els.BlockedUntil.Before(blockEndTime) && els.BlockedUntil.After(*els.CreatedAt.Time)) - if els.BlockedUntil == nil || !blockTimeFitsNow { + blockTimeFitsNow := !els.BlockedUntil.IsNil() && (els.BlockedUntil.Before(blockEndTime) && els.BlockedUntil.After(*els.CreatedAt.Time)) + if !blockTimeFitsNow || els.BlockedUntil.IsNil() { shouldBeBlocked = true } if !shouldBeBlocked { diff --git a/go.mod b/go.mod index 12d91c08..f2a462db 100644 --- a/go.mod +++ b/go.mod @@ -117,7 +117,7 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/onsi/ginkgo/v2 v2.20.0 // indirect + github.com/onsi/ginkgo/v2 v2.20.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/opencontainers/runc v1.1.13 // indirect diff --git a/go.sum b/go.sum index 12d4a938..c79b9b9f 100644 --- a/go.sum +++ b/go.sum @@ -296,8 +296,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw= -github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= +github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo= +github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=