Ensure fibre connection id is created if it doesn’t exist
This commit is contained in:
parent
f19a0f1744
commit
bd9e518f0f
4 changed files with 9 additions and 12 deletions
10
db/db.go
10
db/db.go
|
@ -27,8 +27,8 @@ import (
|
||||||
"github.com/abcum/surreal/kvs"
|
"github.com/abcum/surreal/kvs"
|
||||||
"github.com/abcum/surreal/log"
|
"github.com/abcum/surreal/log"
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
|
|
||||||
"github.com/abcum/surreal/util/data"
|
"github.com/abcum/surreal/util/data"
|
||||||
|
"github.com/abcum/surreal/util/uuid"
|
||||||
|
|
||||||
_ "github.com/abcum/surreal/kvs/rixxdb"
|
_ "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{})
|
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
|
// Get the unique id for this connection
|
||||||
// so that we can assign it to the context
|
// so that we can assign it to the context
|
||||||
// and detect any websocket notifications.
|
// and detect any websocket notifications.
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"github.com/abcum/surreal/mem"
|
"github.com/abcum/surreal/mem"
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/data"
|
"github.com/abcum/surreal/util/data"
|
||||||
"github.com/abcum/surreal/util/uuid"
|
|
||||||
"github.com/dgrijalva/jwt-go"
|
"github.com/dgrijalva/jwt-go"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"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))
|
t.Set(varKeyUniq, c.Get(varKeyUniq))
|
||||||
|
|
||||||
// Create a new socket request id.
|
|
||||||
|
|
||||||
t.Set(varKeySock, uuid.New().String())
|
|
||||||
|
|
||||||
// Give full permissions to scope.
|
// Give full permissions to scope.
|
||||||
|
|
||||||
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB, NS: n, DB: d})
|
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB, NS: n, DB: d})
|
||||||
|
|
|
@ -24,7 +24,6 @@ import (
|
||||||
"github.com/abcum/surreal/mem"
|
"github.com/abcum/surreal/mem"
|
||||||
"github.com/abcum/surreal/sql"
|
"github.com/abcum/surreal/sql"
|
||||||
"github.com/abcum/surreal/util/data"
|
"github.com/abcum/surreal/util/data"
|
||||||
"github.com/abcum/surreal/util/uuid"
|
|
||||||
"github.com/dgrijalva/jwt-go"
|
"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))
|
t.Set(varKeyUniq, c.Get(varKeyUniq))
|
||||||
|
|
||||||
// Create a new socket request id.
|
|
||||||
|
|
||||||
t.Set(varKeySock, uuid.New().String())
|
|
||||||
|
|
||||||
// Give full permissions to scope.
|
// Give full permissions to scope.
|
||||||
|
|
||||||
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB, NS: n, DB: d})
|
t.Set(varKeyAuth, &cnf.Auth{Kind: cnf.AuthDB, NS: n, DB: d})
|
||||||
|
|
|
@ -22,7 +22,6 @@ const (
|
||||||
varKeyUs = "US"
|
varKeyUs = "US"
|
||||||
varKeyTb = "TB"
|
varKeyTb = "TB"
|
||||||
varKeyId = "ID"
|
varKeyId = "ID"
|
||||||
varKeySock = "id"
|
|
||||||
varKeyAuth = "auth"
|
varKeyAuth = "auth"
|
||||||
varKeyUser = "user"
|
varKeyUser = "user"
|
||||||
varKeyPass = "pass"
|
varKeyPass = "pass"
|
||||||
|
|
Loading…
Reference in a new issue