Wrap some errors
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is failing

This commit is contained in:
2022-08-21 19:56:55 +00:00
parent 4ef0b759ef
commit 2f636b5f9c
3 changed files with 12 additions and 9 deletions

View File

@ -63,7 +63,7 @@ func (h *Handler) loginPost(c echo.Context) error {
var login loginInformation
err := c.Bind(&login)
if err != nil {
return err
return fmt.Errorf("parse payload: %w", err)
}
user, err := h.Service.GetUserByUsername(c.Request().Context(), login.User)
@ -72,12 +72,12 @@ func (h *Handler) loginPost(c echo.Context) error {
}
if err = h.CredentialsVerifier.Verify(login.Password, user.Password); err != nil {
return err
return fmt.Errorf("verify password: %w", err)
}
token, err := h.TokenVerifier.CreateToken(&user)
if err != nil {
return err
return fmt.Errorf("create token: %w", err)
}
go h.UpdateLastLogin(user.ID)
@ -120,7 +120,7 @@ func (h *Handler) registerPost(c echo.Context) error {
hash, err := h.CredentialsVerifier.Hash(register.Password)
if err != nil {
return err
return fmt.Errorf("hash password: %w", err)
}
createUser := postgres.CreateUserParams{
@ -135,7 +135,7 @@ func (h *Handler) registerPost(c echo.Context) error {
token, err := h.TokenVerifier.CreateToken(&user)
if err != nil {
return err
return fmt.Errorf("create token: %w", err)
}
go h.UpdateLastLogin(user.ID)