UPDATE: Entity, Geo, Wiki
Some checks failed
Build and Release / release (push) Failing after 1m7s

This commit is contained in:
2026-04-22 17:45:09 +07:00
parent f127e2f029
commit adb65d8292
50 changed files with 3354 additions and 119 deletions

View File

@@ -64,8 +64,16 @@ func (u *userService) ChangePassword(ctx context.Context, userId string, dto *re
return fiber.NewError(fiber.StatusNotFound, "User not found")
}
if err := bcrypt.CompareHashAndPassword([]byte(user.PasswordHash), []byte(dto.OldPassword)); err != nil {
return fiber.NewError(fiber.StatusUnauthorized, "Invalid identity or password!")
if user.PasswordHash != "" {
if dto.OldPassword == "" {
return fiber.NewError(fiber.StatusBadRequest, "Old password required")
}
if err := bcrypt.CompareHashAndPassword([]byte(user.PasswordHash), []byte(dto.OldPassword)); err != nil {
return fiber.NewError(fiber.StatusUnauthorized, "Invalid password!")
}
} else if user.PasswordHash == "" && dto.OldPassword != "" {
return fiber.NewError(fiber.StatusBadRequest, "Invalid request")
}
hashPassword, err := bcrypt.GenerateFromPassword([]byte(dto.NewPassword), bcrypt.DefaultCost)