Fixed not updating the user status in the databse when confirming a token

This commit is contained in:
kolaente 2018-10-27 12:47:15 +02:00
parent 6d62746ce0
commit fd05428d9c
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 16 additions and 8 deletions

View File

@ -9,17 +9,15 @@ Content-Type: application/json
> {% client.global.set("auth_token", response.body.token); %}
###
## Register
### Register
POST http://localhost:8080/api/v1/register
Content-Type: application/json
{
"username": "user3",
"username": "user4",
"password": "1234",
"email": "3@knt.li"
"email": "4@knt.li"
}
###

View File

@ -30,7 +30,7 @@ Accept: application/json
"user_name": "user"
}
### Request a password to reset a password
### Request a token to reset a password
POST http://localhost:8080/api/v1/user/password/reset
Content-Type: application/json
Accept: application/json
@ -41,4 +41,14 @@ Accept: application/json
"new_password": "1234"
}
### Confirm a users email address
POST http://localhost:8080/api/v1/user/confirm
Content-Type: application/json
Accept: application/json
{
"token": "cqucJFxaTBwEZfuQATIBouCvpAfVUWXvrinRXSZpWpxikBMKyBtfNsZysvKOwCPMTsfmHZZeXiHhdBQyAUHFkMiXFAKqzMTWpTTJLkVeoKSkoinlsnxuPiqXjOHJNhnihRtRTdpQARQBlGHBrppojIJwZdKtmXsxwqMDwYKiTuHwjaOKYLeMLQaEWYpmedfvjtwSqhfuitguIatvLbVmtMfEAgwTcHscGeHpPsHFhLMXDqzwCmJYqsXoXxaumMaqaGOTguwvpWXCfvfBSXsjqiTwOcxhdYTRvQNoHijYkzshmrPDwiQcMNyCRzenxaKcrrVPcxJMmMGffjkRQlMtzUyBuHbHLbwQRaadLqPWuKJdXKSjMGiIFzyhCTzOSzMXgSCBtIfRFQaqsUss"
}
###

View File

@ -51,7 +51,7 @@ func CreateUser(user User) (newUser User, err error) {
}
// Generate a confirm token
newUser.EmailConfirmToken = utils.MakeRandomString(150)
newUser.EmailConfirmToken = utils.MakeRandomString(400)
// The new user should not be activated until it confirms his mail address
newUser.IsActive = false

View File

@ -20,6 +20,6 @@ func UserEmailConfirm(c *EmailConfirm) (err error) {
user.IsActive = true
user.EmailConfirmToken = ""
_, err = x.Where("id = ?", user.ID).Update(&user)
_, err = x.Where("id = ?", user.ID).Cols("is_active", "email_confirm_token").Update(&user)
return
}