Skip to content

Commit

Permalink
[BUGFIX] Changer userExist method to prevent non unique identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
kalypso63 committed Oct 11, 2017
1 parent fd80352 commit c569108
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
11 changes: 8 additions & 3 deletions Classes/Service/SocialAuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ public function getUser()
$exist = $this->userExist($hybridUser->identifier);
if ($exist) {
$new = false;
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid='.$exist[0]['uid'], $fields);
$userUid = $exist[0]['uid'];
$GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid='.$exist['uid'], $fields);
$userUid = $exist['uid'];
} else {
//get default user group
$fields['usergroup'] = (int) $this->extConfig['users.']['defaultGroup'];
Expand Down Expand Up @@ -310,7 +310,12 @@ public function getCurrentProvider()
*/
protected function userExist($identifier)
{
return $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('uid', 'fe_users', '1=1 AND pid = '.$this->extConfig['users.']['storagePid'].' AND deleted=0 AND tx_socialauth_identifier LIKE "'.$GLOBALS['TYPO3_DB']->quoteStr($identifier, 'fe_users').'"', '', 'tstamp DESC', 1);
$whereClause = [];
$whereClause[] = 'AND deleted=0';
$whereClause[] = 'AND pid = ' . (int) $this->extConfig['users.']['storagePid'];
$whereClause[] = 'AND tx_socialauth_source = ' . (int) $this->arrayProvider[$this->provider];
$whereClause[] = 'AND tx_socialauth_identifier LIKE "'.$GLOBALS['TYPO3_DB']->quoteStr($identifier, 'fe_users').'"';
return $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('uid', 'fe_users', '1=1 ' . implode(' ', $whereClause), '', 'tstamp DESC');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"homepage": "http://typo3.org",
"license": ["GPL-2.0+"],
"version": "1.2.0",
"version": "1.2.1",
"require": {
"hybridauth/hybridauth": "~2.9.0"
},
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 0,
'version' => '1.2.0',
'version' => '1.2.1',
'constraints' => array(
'depends' => array(
'typo3' => '6.2.0-8.7.99'
Expand Down
2 changes: 2 additions & 0 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
CREATE TABLE fe_users (
tx_socialauth_source int(11) DEFAULT '0' NOT NULL,
tx_socialauth_identifier varchar(255) DEFAULT '' NOT NULL,

INDEX socialauth_idx (tx_socialauth_source, tx_socialauth_identifier)
);

0 comments on commit c569108

Please sign in to comment.