Ensure that the NS and DB are available to the live query

This commit is contained in:
Tobie Morgan Hitchcock 2017-12-12 01:08:32 +00:00
parent 1200b6c209
commit b4c49a7099
2 changed files with 5 additions and 2 deletions

View file

@ -52,7 +52,7 @@ func (d *document) lives(ctx context.Context, when method) (err error) {
if con, ok = sockets[lv.FB]; ok {
ctx = con.ctx()
ctx = con.ctx(d.ns, d.db)
// Check whether this live query has the
// necessary permissions to view this

View file

@ -48,10 +48,13 @@ func flush() {
}
}
func (s *socket) ctx() (ctx context.Context) {
func (s *socket) ctx(ns, db string) (ctx context.Context) {
ctx = context.Background()
ctx = context.WithValue(ctx, ctxKeyNs, ns)
ctx = context.WithValue(ctx, ctxKeyDb, db)
auth := s.fibre.Get(varKeyAuth).(*cnf.Auth)
ctx = context.WithValue(ctx, ctxKeyAuth, auth.Data)
ctx = context.WithValue(ctx, ctxKeyKind, auth.Kind)