modified: serv_nginx/api_bb/internal/handlers/news_handler.go
log createNews method auth
This commit is contained in:
@@ -81,7 +81,12 @@ func (h *NewsHandler) CreateNews(w http.ResponseWriter, r *http.Request) {
|
|||||||
userID, ok := r.Context().Value(middleware.UserIDKey).(uint)
|
userID, ok := r.Context().Value(middleware.UserIDKey).(uint)
|
||||||
logger.Get().Info("userID", zap.Uint("userID", userID))
|
logger.Get().Info("userID", zap.Uint("userID", userID))
|
||||||
if !ok {
|
if !ok {
|
||||||
fmt.Printf("userid %d", userID)
|
h.logger.Warn("Failed to get userID from context in CreateReview",
|
||||||
|
zap.String("path", r.URL.Path),
|
||||||
|
zap.String("method", r.Method),
|
||||||
|
zap.String("remote_addr", r.RemoteAddr),
|
||||||
|
zap.Uint("userID", userID),
|
||||||
|
)
|
||||||
utils.RespondWithError(w, http.StatusUnauthorized, "Unauthorized")
|
utils.RespondWithError(w, http.StatusUnauthorized, "Unauthorized")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user