->signin()
Signs in to a root, namespace, database or scope user.
Method Syntax$db->signin([
"namespace" => "test",
"database" => "db",
"scope" => "scope",
// ... other variables
]);
Arguments
Properties | Description | ||
---|---|---|---|
username | The username of the database user | ||
password | The password of the database user | ||
namespace | The namespace to sign in to | ||
database | The database to sign in to | ||
scope | The scope to sign in to. Also pass any variables used in the scope. Only supported in SurrealDB 1.x | ||
access | The access to sign in to. Also pass any variables used in the access. Only supported from SurrealDB 2.x onwards |
Example usage
// Authenticate with a root user
$token = $db->signin([
"username" => "root",
"password" => "surrealdb",
]);
// Authenticate with a Namespace user
$token = $db->signin([
"namespace" => "surrealdb",
"username" => "tobie",
"password" => "surrealdb",
]);
// Authenticate with a Database user
$token = $db->signin([
"namespace" => "surrealdb",
"database" => "docs",
"username" => "tobie",
"password" => "surrealdb",
]);
// Authenticate with a Scope user
$token = $db->signin([
"namespace" => "surrealdb",
"database" => "docs",
"scope" => "user",
// Also pass any properties required by the scope definition
"email" => "info@surrealdb.com",
"pass" => "123456",
]);
You can invalidate the authentication for the current connection using the invalidate()
method.