From f15dd063fdd230ecd2f9367e3925ac64e9b09853 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 29 Jan 2023 15:11:42 +0545 Subject: [PATCH 1/2] Update src/Appwrite/Migration/Version/V18.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matej Bačo --- src/Appwrite/Migration/Version/V18.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Migration/Version/V18.php b/src/Appwrite/Migration/Version/V18.php index 668544391d..b05d0bc7bb 100644 --- a/src/Appwrite/Migration/Version/V18.php +++ b/src/Appwrite/Migration/Version/V18.php @@ -56,7 +56,7 @@ class V18 extends Migration $this->createAttributeFromCollection($this->projectDB, $id, 'passwordHistory'); $this->projectDB->deleteCachedCollection($id); } catch (\Throwable $th) { - Console::warning("'region' from {$id}: {$th->getMessage()}"); + Console::warning("'passwordHistory' from {$id}: {$th->getMessage()}"); } break; default: From 31b4c73b16f0353006a7cb19a566a216b970320e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 29 Jan 2023 15:30:39 +0545 Subject: [PATCH 2/2] use variable --- app/controllers/api/account.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 66fde19360..e3b4f5d84b 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -498,6 +498,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') try { $userId = ID::unique(); + $password = Auth::passwordHash(Auth::passwordGenerator(), Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS); $user = Authorization::skip(fn() => $dbForProject->createDocument('users', new Document([ '$id' => $userId, '$permissions' => [ @@ -508,8 +509,8 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') 'email' => $email, 'emailVerification' => true, 'status' => true, // Email should already be authenticated by OAuth2 provider - 'passwordHistory' => $passwordHistory > 0 ? [Auth::passwordHash(Auth::passwordGenerator(), Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS)] : null, - 'password' => Auth::passwordHash(Auth::passwordGenerator(), Auth::DEFAULT_ALGO, Auth::DEFAULT_ALGO_OPTIONS), + 'passwordHistory' => $passwordHistory > 0 ? [$password] : null, + 'password' => $password, 'hash' => Auth::DEFAULT_ALGO, 'hashOptions' => Auth::DEFAULT_ALGO_OPTIONS, 'passwordUpdate' => null,