fix: making sure all users can access all functions of all instances
This commit is contained in:
+21
-18
@@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func CreateProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID, err := utils.Auth(w, r, http.MethodPost, "superuser", "admin")
|
||||
_, err := utils.Auth(w, r, http.MethodPost, "superuser", "admin")
|
||||
if err != nil {
|
||||
utils.SendErrorResponse(w, http.StatusUnauthorized, err.Error())
|
||||
postLog.Warning(fmt.Sprintf("[CreateProxyHandler] Auth failed: %v", err))
|
||||
@@ -77,11 +77,12 @@ func CreateProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if instance.UserID != userID {
|
||||
postLog.Error(fmt.Sprintf("[CreateProxyHandler] Instance not found for user %d", userID))
|
||||
utils.SendErrorResponse(w, http.StatusNotFound, "Instance not found")
|
||||
return
|
||||
}
|
||||
// Check if the instance belongs to the user
|
||||
// if instance.UserID != userID {
|
||||
// postLog.Error(fmt.Sprintf("[CreateProxyHandler] Instance not found for user %d", userID))
|
||||
// utils.SendErrorResponse(w, http.StatusNotFound, "Instance not found")
|
||||
// return
|
||||
// }
|
||||
|
||||
configContent, err := os.ReadFile(instance.ConfigPath)
|
||||
if err != nil {
|
||||
@@ -112,7 +113,7 @@ func CreateProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func ModifyProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID, err := utils.Auth(w, r, http.MethodPost, "superuser", "admin")
|
||||
_, err := utils.Auth(w, r, http.MethodPost, "superuser", "admin")
|
||||
if err != nil {
|
||||
utils.SendErrorResponse(w, http.StatusUnauthorized, err.Error())
|
||||
postLog.Warning(fmt.Sprintf("[ModifyProxyHandler] Auth failed: %v", err))
|
||||
@@ -180,11 +181,12 @@ func ModifyProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if instance.UserID != userID {
|
||||
postLog.Error(fmt.Sprintf("[ModifyProxyHandler] Instance not found for user %d", userID))
|
||||
utils.SendErrorResponse(w, http.StatusNotFound, "Instance not found")
|
||||
return
|
||||
}
|
||||
// Check if the instance belongs to the user
|
||||
// if instance.UserID != userID {
|
||||
// postLog.Error(fmt.Sprintf("[ModifyProxyHandler] Instance not found for user %d", userID))
|
||||
// utils.SendErrorResponse(w, http.StatusNotFound, "Instance not found")
|
||||
// return
|
||||
// }
|
||||
|
||||
configContent, err := os.ReadFile(instance.ConfigPath)
|
||||
if err != nil {
|
||||
@@ -215,7 +217,7 @@ func ModifyProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func DeleteProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
userID, err := utils.Auth(w, r, http.MethodPost, "superuser", "admin")
|
||||
_, err := utils.Auth(w, r, http.MethodPost, "superuser", "admin")
|
||||
if err != nil {
|
||||
utils.SendErrorResponse(w, http.StatusUnauthorized, err.Error())
|
||||
postLog.Warning(fmt.Sprintf("[DeleteProxyHandler] Auth failed: %v", err))
|
||||
@@ -260,11 +262,12 @@ func DeleteProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if instance.UserID != userID {
|
||||
postLog.Error(fmt.Sprintf("[DeleteProxyHandler] Instance not found for user %d", userID))
|
||||
utils.SendErrorResponse(w, http.StatusNotFound, "Instance not found")
|
||||
return
|
||||
}
|
||||
// Check if the instance belongs to the user
|
||||
// if instance.UserID != userID {
|
||||
// postLog.Error(fmt.Sprintf("[DeleteProxyHandler] Instance not found for user %d", userID))
|
||||
// utils.SendErrorResponse(w, http.StatusNotFound, "Instance not found")
|
||||
// return
|
||||
// }
|
||||
|
||||
configContent, err := os.ReadFile(instance.ConfigPath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user