fix: reading a single article follows the same rule as the list: anyone can read an online article, a verified user can also read an offline one, and an unknown or hidden id returns 404
This commit is contained in:
1 parent
2ee28203ab
commit
81c4b62175
11 files changed
+510
-28
No files matched your search
@@ -53,7 +53,12 @@ func (h *Handler) GetArticle(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
article, err := h.GetUseCase.GetOnlineArticle(id)
|
||||
var article domain.Article
|
||||
if h.callerIsVerified(r) {
|
||||
article, err = h.GetUseCase.GetArticle(id)
|
||||
} else {
|
||||
article, err = h.GetUseCase.GetOnlineArticle(id)
|
||||
}
|
||||
if err != nil {
|
||||
if errors.Is(err, domain.ErrArticleNotFound) {
|
||||
http.Error(w, apperr.ArticleNotFoundErrorMessage, http.StatusNotFound)
|
||||
|
||||
Reference in new issue
Block a user