added method for check question owner in mw

This commit is contained in:
Pasha 2025-04-22 20:38:49 +03:00 committed by skeris
parent f9f27a544e
commit 2833750049

@ -86,7 +86,24 @@ func (o *OwnerShip) CheckResult(ctx *fiber.Ctx) (bool, error) {
// имеем id вопроса и id аккаунта проверяем что квиз этого вопроса относится к аккаунту
func (o *OwnerShip) CheckQuestion(ctx *fiber.Ctx) (bool, error) {
return true, nil
accountID, ok := middleware.GetAccountId(ctx)
if !ok {
return false, fiber.NewError(fiber.StatusUnauthorized, "account id is required")
}
var body struct {
QuestionID uint64 `json:"id"`
}
if err := ctx.BodyParser(&body); err != nil {
return false, fiber.NewError(fiber.StatusBadRequest, "invalid request data")
}
isOwner, err := o.dal.QuestionRepo.CheckQuestionOwner(ctx.Context(), accountID, body.QuestionID)
if err != nil {
return false, fiber.NewError(fiber.StatusInternalServerError, err.Error())
}
return isOwner, nil
}
// проверка для лид таргета надо проверить что в лид имеет отношение к аккаунту