Fix checking for an email verification token (#10)

This commit is contained in:
konrad 2018-11-01 22:59:20 +00:00 committed by Gitea
parent 9a5eb577b8
commit 9e539b8c40
2 changed files with 7 additions and 1 deletions

View File

@ -47,7 +47,7 @@ Content-Type: application/json
Accept: application/json Accept: application/json
{ {
"token": "cqucJFxaTBwEZfuQATIBouCvpAfVUWXvrinRXSZpWpxikBMKyBtfNsZysvKOwCPMTsfmHZZeXiHhdBQyAUHFkMiXFAKqzMTWpTTJLkVeoKSkoinlsnxuPiqXjOHJNhnihRtRTdpQARQBlGHBrppojIJwZdKtmXsxwqMDwYKiTuHwjaOKYLeMLQaEWYpmedfvjtwSqhfuitguIatvLbVmtMfEAgwTcHscGeHpPsHFhLMXDqzwCmJYqsXoXxaumMaqaGOTguwvpWXCfvfBSXsjqiTwOcxhdYTRvQNoHijYkzshmrPDwiQcMNyCRzenxaKcrrVPcxJMmMGffjkRQlMtzUyBuHbHLbwQRaadLqPWuKJdXKSjMGiIFzyhCTzOSzMXgSCBtIfRFQaqsUss" "token": ""
} }
### ###

View File

@ -8,6 +8,12 @@ type EmailConfirm struct {
// UserEmailConfirm handles the confirmation of an email address // UserEmailConfirm handles the confirmation of an email address
func UserEmailConfirm(c *EmailConfirm) (err error) { 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{} user := User{}
has, err := x.Where("email_confirm_token = ?", c.Token).Get(&user) has, err := x.Where("email_confirm_token = ?", c.Token).Get(&user)
if err != nil { if err != nil {