You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Based on this documentation i have to create multiple instances and for each user an own websocket, or am i wrong?
My Idea (correct me if i'm wrong)
Create a connection with a System user (restricted to specific ns/db), lets name him master
Login using a new method, e.g. checkin which works most exactly like the signin method, but does NOT modify the login itself (stay logged in as master)
This new method only validates the user and returns a token
With that token i can use the database functions by normal, but have to pass the argument token to each endpoint to act as this user (not the master)
Is something possible?
Or even...
The method checkin returns a clone of the db Connection object (or a proxy or something) which i can then use using the same websocket connection?
const db = new Surreal();
db.connect('ws://localhost:8000/rpc', {
namespace: 'test',
database: 'test',
});
db.signin({
// Because we are signin in a database user, we need to let SurrealDB know on which database this user is located.
namespace: 'test',
database: 'test',
username: 'mary',
password: 'VerySecurePassword!',
});
const userDb = db.checkin({
namespace: 'test',
database: 'test',
// Provide the name of the access method
access: 'user',
// Provide the variables used by the signin query
variables: {
email: '[email protected]',
password: 'VerySecurePassword!',
}
});
With that i can query the database normally using db or by user with userDb (enabling also live queries over the same websocket).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey there,
i'd like to connect to surreal on my server only once and then would like to sign in with different users then.
Is there a way to use one Websocket Connection with multiple users?
https://surrealdb.com/docs/surrealdb/security/authentication#sign-in-as-a-record-user
Based on this documentation i have to create multiple instances and for each user an own websocket, or am i wrong?
My Idea (correct me if i'm wrong)
master
checkin
which works most exactly like thesignin
method, but does NOT modify the login itself (stay logged in asmaster
)Is something possible?
Or even...
The method
checkin
returns a clone of the db Connection object (or a proxy or something) which i can then use using the same websocket connection?With that i can query the database normally using
db
or by user withuserDb
(enabling also live queries over the same websocket).Thanks
Beta Was this translation helpful? Give feedback.
All reactions