mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge pull request #5968 from appwrite/feat-implement-migrations
Feat: Move oauth secret to identity
This commit is contained in:
commit
5e4e7ff5a5
2 changed files with 10 additions and 21 deletions
|
|
@ -242,17 +242,6 @@ $commonCollections = [
|
||||||
'default' => null,
|
'default' => null,
|
||||||
'array' => false,
|
'array' => false,
|
||||||
'filters' => ['datetime'],
|
'filters' => ['datetime'],
|
||||||
],
|
|
||||||
[
|
|
||||||
'$id' => ID::custom('migrationsFirebaseServiceAccount'),
|
|
||||||
'type' => Database::VAR_STRING,
|
|
||||||
'format' => '',
|
|
||||||
'size' => 16384,
|
|
||||||
'signed' => true,
|
|
||||||
'required' => false,
|
|
||||||
'default' => null,
|
|
||||||
'array' => false,
|
|
||||||
'filters' => ['encrypt'],
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'indexes' => [
|
'indexes' => [
|
||||||
|
|
|
||||||
|
|
@ -146,14 +146,14 @@ App::post('/v1/migrations/firebase/oauth')
|
||||||
$dbForConsole->updateDocument('identities', $identity->getId(), $identity);
|
$dbForConsole->updateDocument('identities', $identity->getId(), $identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->getAttribute('migrationsFirebaseServiceAccount')) {
|
if ($identity->getAttribute('secret')) {
|
||||||
$serviceAccount = json_decode($user->getAttribute('migrationsFirebaseServiceAccount'), true);
|
$serviceAccount = $identity->getAttribute('secret');
|
||||||
} else {
|
} else {
|
||||||
$serviceAccount = $firebase->createServiceAccount($accessToken, $projectId);
|
$serviceAccount = $firebase->createServiceAccount($accessToken, $projectId);
|
||||||
$user = $user
|
$identity = $identity
|
||||||
->setAttribute('migrationsFirebaseServiceAccount', json_encode($serviceAccount));
|
->setAttribute('secret', $serviceAccount);
|
||||||
|
|
||||||
$dbForConsole->updateDocument('users', $user->getId(), $user);
|
$dbForConsole->updateDocument('identities', $identity->getId(), $identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
$migration = $dbForProject->createDocument('migrations', new Document([
|
$migration = $dbForProject->createDocument('migrations', new Document([
|
||||||
|
|
@ -542,14 +542,14 @@ App::get('/v1/migrations/firebase/report/oauth')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Service Account
|
// Get Service Account
|
||||||
if ($user->getAttribute('migrationsFirebaseServiceAccount')) {
|
if ($identity->getAttribute('secret')) {
|
||||||
$serviceAccount = json_decode($user->getAttribute('migrationsFirebaseServiceAccount'), true);
|
$serviceAccount = $identity->getAttribute('secret');
|
||||||
} else {
|
} else {
|
||||||
$serviceAccount = $firebase->createServiceAccount($accessToken, $projectId);
|
$serviceAccount = $firebase->createServiceAccount($accessToken, $projectId);
|
||||||
$user = $user
|
$identity = $identity
|
||||||
->setAttribute('migrationsFirebaseServiceAccount', json_encode($serviceAccount));
|
->setAttribute('secret', $serviceAccount);
|
||||||
|
|
||||||
$dbForConsole->updateDocument('users', $user->getId(), $user);
|
$dbForConsole->updateDocument('identities', $identity->getId(), $identity);
|
||||||
}
|
}
|
||||||
|
|
||||||
$firebase = new Firebase(array_merge($serviceAccount, ['project_id' => $projectId]));
|
$firebase = new Firebase(array_merge($serviceAccount, ['project_id' => $projectId]));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue