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)
|
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())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user