Use AbortWithError
This commit is contained in:
parent
7c8698da86
commit
649b272caf
@ -122,18 +122,18 @@ func (h *Handler) loginPost(c *gin.Context) {
|
||||
|
||||
user, err := h.UserService.UserByUsername(username)
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
c.AbortWithError(http.StatusUnauthorized, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err = h.CredentialsVerifier.Verify(password, user.Password); err != nil {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
c.AbortWithError(http.StatusUnauthorized, err)
|
||||
return
|
||||
}
|
||||
|
||||
t, err := h.TokenVerifier.CreateToken(user)
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
c.AbortWithError(http.StatusUnauthorized, err)
|
||||
}
|
||||
|
||||
maxAge := (int)((expiration * time.Hour).Seconds())
|
||||
|
Loading…
x
Reference in New Issue
Block a user