fixed viewing invisible releases with admin session
This commit is contained in:
parent
1efe52a8cb
commit
70825ae875
5 changed files with 46 additions and 36 deletions
|
@ -3,6 +3,7 @@ package view
|
|||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"arimelody-web/controller"
|
||||
"arimelody-web/model"
|
||||
|
@ -59,7 +60,13 @@ func ServeGateway(app *model.AppState, release *model.Release) http.Handler {
|
|||
// only allow authorised users to view hidden releases
|
||||
privileged := false
|
||||
if !release.Visible {
|
||||
session := r.Context().Value("session").(*model.Session)
|
||||
session, err := controller.GetSessionFromRequest(app.DB, r)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "WARN: Failed to retrieve session: %v\n", err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
if session != nil && session.Account != nil {
|
||||
// TODO: check privilege on release
|
||||
privileged = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue