Field is called email not username
This commit is contained in:
parent
518a0c2df9
commit
97ca85a0db
11
http/http.go
11
http/http.go
@ -134,25 +134,26 @@ func (h *Handler) loginPost(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handler) registerPost(c *gin.Context) {
|
func (h *Handler) registerPost(c *gin.Context) {
|
||||||
username, _ := c.GetPostForm("username")
|
email, _ := c.GetPostForm("email")
|
||||||
password, _ := c.GetPostForm("password")
|
password, _ := c.GetPostForm("password")
|
||||||
name, _ := c.GetPostForm("name")
|
name, _ := c.GetPostForm("name")
|
||||||
|
|
||||||
user, err := h.UserService.UserByUsername(username)
|
user, err := h.UserService.UserByUsername(email)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
c.AbortWithStatus(http.StatusUnauthorized)
|
c.AbortWithStatus(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
hash, err := h.CredentialsVerifier.Hash(password)
|
hash, err := h.CredentialsVerifier.Hash(password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithStatus(http.StatusUnauthorized)
|
c.AbortWithError(http.StatusUnauthorized, err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user = &budgeteer.User{
|
user = &budgeteer.User{
|
||||||
Name: name,
|
Name: name,
|
||||||
Password: hash,
|
Password: hash,
|
||||||
Email: username,
|
Email: email,
|
||||||
}
|
}
|
||||||
err = h.UserService.CreateUser(user)
|
err = h.UserService.CreateUser(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user