From 97ca85a0dbc92a152c733dda0e3b7cc0112887eb Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Tue, 20 Dec 2016 16:38:48 +0100 Subject: [PATCH] Field is called email not username --- http/http.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/http/http.go b/http/http.go index 7be6299..ed39fc7 100644 --- a/http/http.go +++ b/http/http.go @@ -134,25 +134,26 @@ func (h *Handler) loginPost(c *gin.Context) { } func (h *Handler) registerPost(c *gin.Context) { - username, _ := c.GetPostForm("username") + email, _ := c.GetPostForm("email") password, _ := c.GetPostForm("password") name, _ := c.GetPostForm("name") - user, err := h.UserService.UserByUsername(username) - if err != nil { + user, err := h.UserService.UserByUsername(email) + if err == nil { c.AbortWithStatus(http.StatusUnauthorized) return } hash, err := h.CredentialsVerifier.Hash(password) if err != nil { - c.AbortWithStatus(http.StatusUnauthorized) + c.AbortWithError(http.StatusUnauthorized, err) + return } user = &budgeteer.User{ Name: name, Password: hash, - Email: username, + Email: email, } err = h.UserService.CreateUser(user) if err != nil {