mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
adapt to anon login
This commit is contained in:
@@ -334,7 +334,7 @@ $collections = [
|
||||
'key' => 'providerUid',
|
||||
'type' => Database::SYSTEM_VAR_TYPE_TEXT,
|
||||
'default' => '',
|
||||
'required' => true,
|
||||
'required' => false,
|
||||
'array' => false,
|
||||
],
|
||||
[
|
||||
|
||||
@@ -650,10 +650,10 @@ App::post('/v1/account/sessions/anonymous')
|
||||
$expiry = \time() + Auth::TOKEN_EXPIRATION_LOGIN_LONG;
|
||||
$session = new Document(array_merge(
|
||||
[
|
||||
'$collection' => Database::SYSTEM_COLLECTION_TOKENS,
|
||||
'$collection' => Database::SYSTEM_COLLECTION_SESSIONS,
|
||||
'$permissions' => ['read' => ['user:' . $user['$id']], 'write' => ['user:' . $user['$id']]],
|
||||
'userId' => $user->getId(),
|
||||
'type' => Auth::TOKEN_TYPE_LOGIN,
|
||||
'provider' => Auth::SESSION_PROVIDER_ANONYMOUS,
|
||||
'secret' => Auth::hash($secret), // One way hash encryption to protect DB leak
|
||||
'expire' => $expiry,
|
||||
'userAgent' => $request->getUserAgent('UNKNOWN'),
|
||||
@@ -665,7 +665,7 @@ App::post('/v1/account/sessions/anonymous')
|
||||
$detector->getDevice()
|
||||
));
|
||||
|
||||
$user->setAttribute('tokens', $session, Document::SET_TYPE_APPEND);
|
||||
$user->setAttribute('sessions', $session, Document::SET_TYPE_APPEND);
|
||||
|
||||
Authorization::setRole('user:'.$user->getId());
|
||||
|
||||
|
||||
@@ -31,20 +31,20 @@ class Session extends Model
|
||||
->addRule('provider', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Session Provider.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'default' => '',
|
||||
'example' => 'email',
|
||||
])
|
||||
->addRule('providerUid', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Session Provider User ID.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'default' => '',
|
||||
'example' => 'user@example.com',
|
||||
])
|
||||
->addRule('providerToken', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Session Provider Token.',
|
||||
'default' => 0,
|
||||
'example' => 1592981250,
|
||||
'default' => '',
|
||||
'example' => '1592981250',
|
||||
])
|
||||
->addRule('ip', [
|
||||
'type' => self::TYPE_STRING,
|
||||
|
||||
Reference in New Issue
Block a user