session profile decoupled.

This commit is contained in:
Miroslav Šedivý
2021-03-14 00:45:51 +01:00
parent 7d4f7694b9
commit 4a28307c1e
15 changed files with 38 additions and 79 deletions

View File

@ -41,7 +41,7 @@ func (h *RoomHandler) controlRequest(w http.ResponseWriter, r *http.Request) {
}
session := auth.GetSession(r)
if !session.CanHost() {
if !session.Profile().CanHost {
utils.HttpBadRequest(w, "Session is not allowed to host.")
return
}
@ -58,7 +58,7 @@ func (h *RoomHandler) controlRelease(w http.ResponseWriter, r *http.Request) {
return
}
if !session.CanHost() {
if !session.Profile().CanHost {
utils.HttpBadRequest(w, "Session is not allowed to host.")
return
}
@ -71,7 +71,7 @@ func (h *RoomHandler) controlRelease(w http.ResponseWriter, r *http.Request) {
func (h *RoomHandler) controlTake(w http.ResponseWriter, r *http.Request) {
session := auth.GetSession(r)
if !session.CanHost() {
if !session.Profile().CanHost {
utils.HttpBadRequest(w, "Session is not allowed to host.")
return
}
@ -90,7 +90,7 @@ func (h *RoomHandler) controlGive(w http.ResponseWriter, r *http.Request) {
return
}
if !target.CanHost() {
if !target.Profile().CanHost {
utils.HttpBadRequest(w, "Target session is not allowed to host.")
return
}

View File

@ -89,7 +89,7 @@ func (h *RoomHandler) Route(r chi.Router) {
func (h *RoomHandler) uploadMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
session := auth.GetSession(r)
if !session.IsHost() && (!session.CanHost() || !h.sessions.ImplicitHosting()) {
if !session.IsHost() && (!session.Profile().CanHost || !h.sessions.ImplicitHosting()) {
utils.HttpForbidden(w, "Without implicit hosting, only host can upload files.")
} else {
next.ServeHTTP(w, r)