feat: add file visibility toggle for files
This commit is contained in:
@ -3,6 +3,7 @@ package downloadHandler
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fossyy/filekeeper/app"
|
||||
"github.com/fossyy/filekeeper/session"
|
||||
"github.com/fossyy/filekeeper/types/models"
|
||||
"io"
|
||||
"net/http"
|
||||
@ -21,6 +22,17 @@ func GET(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
status, userSession, _ := session.GetSession(r)
|
||||
if file.IsPrivate {
|
||||
if status == session.Unauthorized || status == session.InvalidSession {
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
} else if file.OwnerID != userSession.UserID {
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
uploadDir := "uploads"
|
||||
currentDir, _ := os.Getwd()
|
||||
basePath := filepath.Join(currentDir, uploadDir)
|
||||
|
Reference in New Issue
Block a user