Ensure fibre connection id is created if it doesn’t exist

This commit is contained in:
Tobie Morgan Hitchcock 2019-02-01 01:17:41 +00:00
parent f19a0f1744
commit bd9e518f0f
4 changed files with 9 additions and 12 deletions

View file

@ -27,8 +27,8 @@ import (
"github.com/abcum/surreal/kvs"
"github.com/abcum/surreal/log"
"github.com/abcum/surreal/sql"
"github.com/abcum/surreal/util/data"
"github.com/abcum/surreal/util/uuid"
_ "github.com/abcum/surreal/kvs/rixxdb"
)
@ -158,6 +158,14 @@ func Process(fib *fibre.Context, ast *sql.Query, vars map[string]interface{}) (o
vars = make(map[string]interface{})
}
// Ensure that we have a unique id assigned
// to this fibre connection, as we need it
// to detect unique websocket notifications.
if fib.Get(ctxKeyId) == nil {
fib.Set(ctxKeyId, uuid.New().String())
}
// Get the unique id for this connection
// so that we can assign it to the context
// and detect any websocket notifications.

View file

@ -24,7 +24,6 @@ import (
"github.com/abcum/surreal/mem"
"github.com/abcum/surreal/sql"
"github.com/abcum/surreal/util/data"
"github.com/abcum/surreal/util/uuid"
"github.com/dgrijalva/jwt-go"
"golang.org/x/crypto/bcrypt"
)
@ -110,10 +109,6 @@ func signinInternal(c *fibre.Context, vars map[string]interface{}) (str string,
t.Set(varKeyUniq, c.Get(varKeyUniq))
// Create a new socket request id.
t.Set(varKeySock, uuid.New().String())
// Give full permissions to scope.
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB, NS: n, DB: d})

View file

@ -24,7 +24,6 @@ import (
"github.com/abcum/surreal/mem"
"github.com/abcum/surreal/sql"
"github.com/abcum/surreal/util/data"
"github.com/abcum/surreal/util/uuid"
"github.com/dgrijalva/jwt-go"
)
@ -109,10 +108,6 @@ func signupInternal(c *fibre.Context, vars map[string]interface{}) (str string,
t.Set(varKeyUniq, c.Get(varKeyUniq))
// Create a new socket request id.
t.Set(varKeySock, uuid.New().String())
// Give full permissions to scope.
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB, NS: n, DB: d})

View file

@ -22,7 +22,6 @@ const (
varKeyUs = "US"
varKeyTb = "TB"
varKeyId = "ID"
varKeySock = "id"
varKeyAuth = "auth"
varKeyUser = "user"
varKeyPass = "pass"