diff --git a/db/db_test.go b/db/db_test.go index 852419ba..117c6734 100644 --- a/db/db_test.go +++ b/db/db_test.go @@ -19,6 +19,7 @@ import ( "github.com/abcum/fibre" "github.com/abcum/surreal/cnf" + "github.com/abcum/surreal/util/uuid" ) func setupDB(workers ...int) { @@ -52,6 +53,7 @@ func setupKV() *fibre.Context { res := &fibre.Response{} ctx := fibre.NewContext(req, res, nil) + ctx.Set("id", uuid.New().String()) ctx.Set("auth", auth) return ctx @@ -71,6 +73,7 @@ func setupSC() *fibre.Context { res := &fibre.Response{} ctx := fibre.NewContext(req, res, nil) + ctx.Set("id", uuid.New().String()) ctx.Set("auth", auth) return ctx diff --git a/web/signin.go b/web/signin.go index 6bcda980..51f5bdd0 100644 --- a/web/signin.go +++ b/web/signin.go @@ -24,6 +24,7 @@ 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" ) @@ -105,10 +106,14 @@ func signinInternal(c *fibre.Context, vars map[string]interface{}) (str string, c.Fibre(), ) - // Ensure we copy the session od. + // Ensure we copy the session id. 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}) diff --git a/web/signup.go b/web/signup.go index 6f8abda5..58a5f0f3 100644 --- a/web/signup.go +++ b/web/signup.go @@ -24,6 +24,7 @@ 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" ) @@ -104,10 +105,14 @@ func signupInternal(c *fibre.Context, vars map[string]interface{}) (str string, c.Fibre(), ) - // Ensure we copy the session od. + // Ensure we copy the session id. 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}) diff --git a/web/vars.go b/web/vars.go index 3d9df8a9..881392bc 100644 --- a/web/vars.go +++ b/web/vars.go @@ -22,6 +22,7 @@ const ( varKeyUs = "US" varKeyTb = "TB" varKeyId = "ID" + varKeySock = "id" varKeyAuth = "auth" varKeyUser = "user" varKeyPass = "pass"