diff options
author | Friendika <info@friendika.com> | 2011-03-24 15:45:27 -0700 |
---|---|---|
committer | Friendika <info@friendika.com> | 2011-03-24 15:45:27 -0700 |
commit | 6bc5d6f17b9d86d909cf43cde0a399b17c46bbf5 (patch) | |
tree | a960695183f23f9267e56079395198a40fb72b06 | |
parent | 067626380db6d5ed71d68bd91481ff51cfa76915 (diff) | |
download | volse-hubzilla-6bc5d6f17b9d86d909cf43cde0a399b17c46bbf5.tar.gz volse-hubzilla-6bc5d6f17b9d86d909cf43cde0a399b17c46bbf5.tar.bz2 volse-hubzilla-6bc5d6f17b9d86d909cf43cde0a399b17c46bbf5.zip |
repair duplicate nickname accounts caused by race condition
-rw-r--r-- | boot.php | 2 | ||||
-rw-r--r-- | mod/register.php | 18 |
2 files changed, 19 insertions, 1 deletions
@@ -2,7 +2,7 @@ set_time_limit(0); -define ( 'FRIENDIKA_VERSION', '2.1.927' ); +define ( 'FRIENDIKA_VERSION', '2.1.928' ); define ( 'DFRN_PROTOCOL_VERSION', '2.1' ); define ( 'DB_UPDATE_VERSION', 1045 ); diff --git a/mod/register.php b/mod/register.php index 95e9d581f..06ed1e0f1 100644 --- a/mod/register.php +++ b/mod/register.php @@ -199,6 +199,24 @@ function register_post(&$a) { return; } + /** + * if somebody clicked submit twice very quickly, they could end up with two accounts + * due to race condition. Remove this one. + */ + + $r = q("SELECT `uid` FROM `user` + WHERE `nickname` = '%s' ", + dbesc($nickname) + ); + if((count($r) > 1) && $newuid) { + $err .= t('Nickname is already registered. Please choose another.') . EOL; + q("DELETE FROM `user` WHERE `uid` = %d LIMIT 1", + intval($newuid) + ); + notice ($err); + return; + } + if(x($newuid) !== false) { $r = q("INSERT INTO `profile` ( `uid`, `profile-name`, `is-default`, `name`, `photo`, `thumb`, `publish`, `net-publish` ) VALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, %d ) ", |