From 9e539b8c40e3b8a37bf68a031d2a95708aa03ad1 Mon Sep 17 00:00:00 2001 From: konrad Date: Thu, 1 Nov 2018 22:59:20 +0000 Subject: [PATCH] Fix checking for an email verification token (#10) --- REST-Tests/users.http | 2 +- pkg/models/user_email_confirm.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/REST-Tests/users.http b/REST-Tests/users.http index e8c066fa..2f3ca6ff 100644 --- a/REST-Tests/users.http +++ b/REST-Tests/users.http @@ -47,7 +47,7 @@ Content-Type: application/json Accept: application/json { - "token": "cqucJFxaTBwEZfuQATIBouCvpAfVUWXvrinRXSZpWpxikBMKyBtfNsZysvKOwCPMTsfmHZZeXiHhdBQyAUHFkMiXFAKqzMTWpTTJLkVeoKSkoinlsnxuPiqXjOHJNhnihRtRTdpQARQBlGHBrppojIJwZdKtmXsxwqMDwYKiTuHwjaOKYLeMLQaEWYpmedfvjtwSqhfuitguIatvLbVmtMfEAgwTcHscGeHpPsHFhLMXDqzwCmJYqsXoXxaumMaqaGOTguwvpWXCfvfBSXsjqiTwOcxhdYTRvQNoHijYkzshmrPDwiQcMNyCRzenxaKcrrVPcxJMmMGffjkRQlMtzUyBuHbHLbwQRaadLqPWuKJdXKSjMGiIFzyhCTzOSzMXgSCBtIfRFQaqsUss" + "token": "" } ### diff --git a/pkg/models/user_email_confirm.go b/pkg/models/user_email_confirm.go index a9c177ee..abe23e44 100644 --- a/pkg/models/user_email_confirm.go +++ b/pkg/models/user_email_confirm.go @@ -8,6 +8,12 @@ type EmailConfirm struct { // UserEmailConfirm handles the confirmation of an email address func UserEmailConfirm(c *EmailConfirm) (err error) { + // Check if we have an email confirm token + if c.Token == "" { + return ErrInvalidEmailConfirmToken{} + } + + // Check if the token is valid user := User{} has, err := x.Where("email_confirm_token = ?", c.Token).Get(&user) if err != nil {