diff --git a/db/db.go b/db/db.go index 7ed2b693..f0f787cd 100644 --- a/db/db.go +++ b/db/db.go @@ -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. diff --git a/web/signin.go b/web/signin.go index b199162f..4205d238 100644 --- a/web/signin.go +++ b/web/signin.go @@ -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}) diff --git a/web/signup.go b/web/signup.go index 75a2ce7f..d9627486 100644 --- a/web/signup.go +++ b/web/signup.go @@ -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}) diff --git a/web/vars.go b/web/vars.go index 881392bc..3d9df8a9 100644 --- a/web/vars.go +++ b/web/vars.go @@ -22,7 +22,6 @@ const ( varKeyUs = "US" varKeyTb = "TB" varKeyId = "ID" - varKeySock = "id" varKeyAuth = "auth" varKeyUser = "user" varKeyPass = "pass"