mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
Merge pull request #3221 from appwrite/fix-oauth2-verification
fix: OAuth2 verification
This commit is contained in:
commit
e9029efbbc
1 changed files with 9 additions and 8 deletions
|
|
@ -475,15 +475,16 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||||
if ($user === false || $user->isEmpty()) { // No user logged in or with OAuth2 provider ID, create new one or connect with account with same email
|
if ($user === false || $user->isEmpty()) { // No user logged in or with OAuth2 provider ID, create new one or connect with account with same email
|
||||||
$name = $oauth2->getUserName($accessToken);
|
$name = $oauth2->getUserName($accessToken);
|
||||||
$email = $oauth2->getUserEmail($accessToken);
|
$email = $oauth2->getUserEmail($accessToken);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is verified is not used yet, since we don't know after an accout is created anymore if it was verified or not.
|
||||||
|
*/
|
||||||
$isVerified = $oauth2->isEmailVerified($accessToken);
|
$isVerified = $oauth2->isEmailVerified($accessToken);
|
||||||
|
|
||||||
if ($isVerified === true) {
|
$user = $dbForProject->findOne('users', [
|
||||||
// Get user by email address
|
new Query('deleted', Query::TYPE_EQUAL, [false]),
|
||||||
$user = $dbForProject->findOne('users', [
|
new Query('email', Query::TYPE_EQUAL, [$email])]
|
||||||
new Query('deleted', Query::TYPE_EQUAL, [false]),
|
);
|
||||||
new Query('email', Query::TYPE_EQUAL, [$email])]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($user === false || $user->isEmpty()) { // Last option -> create the user, generate random password
|
if ($user === false || $user->isEmpty()) { // Last option -> create the user, generate random password
|
||||||
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
|
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
|
||||||
|
|
@ -503,7 +504,7 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect')
|
||||||
'$read' => ['role:all'],
|
'$read' => ['role:all'],
|
||||||
'$write' => ['user:' . $userId],
|
'$write' => ['user:' . $userId],
|
||||||
'email' => $email,
|
'email' => $email,
|
||||||
'emailVerification' => $isVerified,
|
'emailVerification' => true,
|
||||||
'status' => true, // Email should already be authenticated by OAuth2 provider
|
'status' => true, // Email should already be authenticated by OAuth2 provider
|
||||||
'password' => Auth::passwordHash(Auth::passwordGenerator()),
|
'password' => Auth::passwordHash(Auth::passwordGenerator()),
|
||||||
'passwordUpdate' => 0,
|
'passwordUpdate' => 0,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue