From d309d5b3b6d55b1508cb2cd539313f7b88369714 Mon Sep 17 00:00:00 2001 From: konrad Date: Tue, 23 Jan 2018 16:20:37 +0100 Subject: [PATCH] fixed lint + gofmt --- models/error.go | 2 +- routes/api/v1/user_show.go | 5 +++-- routes/api/v1/user_update_password.go | 7 +++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/models/error.go b/models/error.go index 203858d..cd4e80c 100644 --- a/models/error.go +++ b/models/error.go @@ -42,7 +42,7 @@ type ErrUserDoesNotExist struct { UserID int64 } -// IsErrNoUsername checks if an error is a ErrUsernameExists. +// IsErrUserDoesNotExist checks if an error is a ErrUsernameExists. func IsErrUserDoesNotExist(err error) bool { _, ok := err.(ErrUserDoesNotExist) return ok diff --git a/routes/api/v1/user_show.go b/routes/api/v1/user_show.go index cb4476e..db7b140 100644 --- a/routes/api/v1/user_show.go +++ b/routes/api/v1/user_show.go @@ -1,12 +1,13 @@ package v1 import ( + "git.mowie.cc/konrad/Library/models" "github.com/labstack/echo" "net/http" "strconv" - "git.mowie.cc/konrad/Library/models" ) +// UserShow gets all informations about a user func UserShow(c echo.Context) error { // Check if the user is admin @@ -39,4 +40,4 @@ func UserShow(c echo.Context) error { } return c.JSON(http.StatusOK, userInfos) -} \ No newline at end of file +} diff --git a/routes/api/v1/user_update_password.go b/routes/api/v1/user_update_password.go index e33a9ba..685b58e 100644 --- a/routes/api/v1/user_update_password.go +++ b/routes/api/v1/user_update_password.go @@ -4,8 +4,8 @@ import ( "net/http" "strconv" - "github.com/labstack/echo" "git.mowie.cc/konrad/Library/models" + "github.com/labstack/echo" ) type datPassword struct { @@ -28,7 +28,6 @@ func UserChangePassword(c echo.Context) error { return c.JSON(http.StatusInternalServerError, models.Message{"Error getting user infos."}) } - // Check if the user is admin or itself userJWTinfo, err := models.GetCurrentUser(c) if !models.IsAdmin(c) || userJWTinfo.ID == userID { @@ -59,7 +58,7 @@ func UserChangePassword(c echo.Context) error { if !exists { return c.JSON(http.StatusNotFound, models.Message{"User not found."}) } - + err = models.UpdateUserPassword(userID, datPw.Password) if err != nil { @@ -67,4 +66,4 @@ func UserChangePassword(c echo.Context) error { } return c.JSON(http.StatusOK, models.Message{"The password was updated successfully"}) -} \ No newline at end of file +}