fixed
This commit is contained in:
+12
-2
@@ -82,10 +82,20 @@ func AuthorizeHandler(w http.ResponseWriter, r *http.Request) {
|
||||
// Return result
|
||||
if result.Allowed {
|
||||
log.Printf("✓ [Handler] Authorization ALLOWED - Returning 200 OK to client")
|
||||
helper.RespondWithJSON(w, http.StatusOK, result)
|
||||
// Return response matching AuthorizationResponse model for client compatibility
|
||||
response := map[string]interface{}{
|
||||
"allowed": result.Allowed,
|
||||
"reason": result.Message,
|
||||
}
|
||||
helper.RespondWithJSON(w, http.StatusOK, response)
|
||||
} else {
|
||||
log.Printf("✗ [Handler] Authorization DENIED - Returning 403 Forbidden to client (reason: %s)", result.Message)
|
||||
helper.RespondWithJSON(w, http.StatusForbidden, result)
|
||||
// Return response matching AuthorizationResponse model for client compatibility
|
||||
response := map[string]interface{}{
|
||||
"allowed": result.Allowed,
|
||||
"reason": result.Message,
|
||||
}
|
||||
helper.RespondWithJSON(w, http.StatusForbidden, response)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user