Skip to content
Code-Schnipsel Gruppen Projekte
Commit c063e511 erstellt von Patrick Müller's avatar Patrick Müller
Dateien durchsuchen

feat: automatically connect google account if a user with the google email...

feat: automatically connect google account if a user with the google email address already exists in the system
Übergeordneter ea172f61
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -7,6 +7,8 @@
namespace QUI\Auth\Google;
use QUI;
use QUI\Auth\Google\Exception as GoogleException;
use QUI\Auth\Google\Exception as GoogleException;
use QUI\Users\AbstractAuthenticator;
use QUI\Users\User;
use QUI\Auth\Google\Exception as GoogleException;
......@@ -101,10 +103,33 @@ public function auth($authData)
$connectionProfile = Google::getConnectedAccountByGoogleIdToken($token);
if (empty($connectionProfile)) {
throw new GoogleException([
'quiqqer/authgoogle',
'exception.auth.no.account.connected'
], 1001);
/**
* Check if a user with the Facebook e-mail address already exists and if so
* automatically connect it to the QUIQQER account.
*/
$userData = Google::getProfileData($token);
$Users = QUI::getUsers();
if (!empty($userData['email']) && $Users->emailExists($userData['email'])) {
try {
$User = $Users->getUserByMail($userData['email']);
Google::connectQuiqqerAccount($User->getId(), $token, false);
$connectionProfile = Google::getConnectedAccountByGoogleIdToken($token);
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
throw new GoogleException([
'quiqqer/authgoogle',
'exception.auth.no.account.connected'
], 1001);
}
} else {
throw new GoogleException([
'quiqqer/authgoogle',
'exception.auth.no.account.connected'
], 1001);
}
}
// if there is no user set, Google is used as primary login
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren