1
0
Fork 0
mirror of synced 2024-06-14 00:34:51 +12:00

Backwards compatible approach

This commit is contained in:
Matej Bačo 2024-05-14 12:33:49 +00:00
parent 4d249c5d36
commit 37176e7865
3 changed files with 9 additions and 2 deletions

View file

@ -1148,7 +1148,7 @@ App::post('/v1/projects/:projectId/keys')
'expire' => $expire,
'sdks' => [],
'accessedAt' => null,
'secret' => API_KEY_STANDARD . '_' . \bin2hex(\random_bytes(128)),
'secret' => \bin2hex(\random_bytes(128)),
]);
$key = $dbForConsole->createDocument('keys', $key);

View file

@ -242,7 +242,7 @@ App::init()
// Regular key
// Check if given key match project API keys
$key = $project->find('secret', $apiKey, 'keys');
$key = $project->find('secret', $authKey, 'keys');
if ($key) {
$user = new Document([
'$id' => '',

View file

@ -4,6 +4,7 @@ namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
use Utopia\Database\Document;
class Key extends Model
{
@ -93,4 +94,10 @@ class Key extends Model
{
return Response::MODEL_KEY;
}
public function filter(Document $document): Document
{
$document->setAttribute('secret', API_KEY_STANDARD . '_' . $document->getAttribute('secret', ''));
return $document;
}
}