Use AbortWithError

This commit is contained in:
Jan Bader 2016-12-27 00:28:19 +01:00
parent 7c8698da86
commit 649b272caf

View File

@ -122,18 +122,18 @@ func (h *Handler) loginPost(c *gin.Context) {
user, err := h.UserService.UserByUsername(username) user, err := h.UserService.UserByUsername(username)
if err != nil { if err != nil {
c.AbortWithStatus(http.StatusUnauthorized) c.AbortWithError(http.StatusUnauthorized, err)
return return
} }
if err = h.CredentialsVerifier.Verify(password, user.Password); err != nil { if err = h.CredentialsVerifier.Verify(password, user.Password); err != nil {
c.AbortWithStatus(http.StatusUnauthorized) c.AbortWithError(http.StatusUnauthorized, err)
return return
} }
t, err := h.TokenVerifier.CreateToken(user) t, err := h.TokenVerifier.CreateToken(user)
if err != nil { if err != nil {
c.AbortWithStatus(http.StatusUnauthorized) c.AbortWithError(http.StatusUnauthorized, err)
} }
maxAge := (int)((expiration * time.Hour).Seconds()) maxAge := (int)((expiration * time.Hour).Seconds())