mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
fix control give for users.
This commit is contained in:
parent
c0e5804b3b
commit
667a54e9d9
@ -95,7 +95,7 @@ func (h *RoomHandler) Route(r types.Router) {
|
||||
r.Post("/release", h.controlRelease)
|
||||
|
||||
r.With(auth.AdminsOnly).Post("/take", h.controlTake)
|
||||
r.With(auth.AdminsOnly).Post("/give/{sessionId}", h.controlGive)
|
||||
r.With(auth.HostsOrAdminsOnly).Post("/give/{sessionId}", h.controlGive)
|
||||
r.With(auth.AdminsOnly).Post("/reset", h.controlReset)
|
||||
})
|
||||
|
||||
|
@ -100,7 +100,6 @@ func (s *session) wsToBackend(msg []byte, sendMsg func([]byte) error) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: Not implemented for user - only for admins.
|
||||
return s.apiReq(http.MethodPost, "/api/room/control/give/"+request.ID, nil, nil)
|
||||
|
||||
case oldEvent.CONTROL_CLIPBOARD:
|
||||
|
@ -40,6 +40,15 @@ func HostsOnly(w http.ResponseWriter, r *http.Request) (context.Context, error)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func HostsOrAdminsOnly(w http.ResponseWriter, r *http.Request) (context.Context, error) {
|
||||
session, ok := GetSession(r)
|
||||
if !ok || (!session.IsHost() && !session.Profile().IsAdmin) {
|
||||
return nil, utils.HttpForbidden("session is not host or admin")
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func CanWatchOnly(w http.ResponseWriter, r *http.Request) (context.Context, error) {
|
||||
session, ok := GetSession(r)
|
||||
if !ok || !session.Profile().CanWatch {
|
||||
|
Loading…
Reference in New Issue
Block a user