From fa706c8e860d4057f401b3ca0dff04fb8aa47363 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 9 Jul 2014 21:10:56 -0700 Subject: finish implementing email verification. Currently it only applies if REGISTER_OPEN is in effect. --- boot.php | 2 +- include/account.php | 9 ++++++++- include/auth.php | 7 ++++++- install/update.php | 10 +++++++++- mod/register.php | 23 +++++++++++++++++++---- version.inc | 2 +- 6 files changed, 44 insertions(+), 9 deletions(-) diff --git a/boot.php b/boot.php index 54ef9486e..c3ea2a854 100755 --- a/boot.php +++ b/boot.php @@ -47,7 +47,7 @@ define ( 'RED_PLATFORM', 'Red Matrix' ); define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'ZOT_REVISION', 1 ); -define ( 'DB_UPDATE_VERSION', 1115 ); +define ( 'DB_UPDATE_VERSION', 1116 ); define ( 'EOL', '
' . "\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/include/account.php b/include/account.php index edfd1bf05..138db3290 100644 --- a/include/account.php +++ b/include/account.php @@ -254,6 +254,7 @@ function verify_email_address($arr) { else logger('send_reg_approval_email: failed to ' . $admin['email'] . 'account_id: ' . $arr['account']['account_id']); + return $res; } @@ -476,8 +477,14 @@ function user_approve($hash) { intval(ACCOUNT_PENDING), intval($register[0]['uid']) ); + $r = q("update account set account_flags = (account_flags ^ %d) where (account_flags & %d) and account_id = %d limit 1", + intval(ACCOUNT_UNVERIFIED), + intval(ACCOUNT_UNVERIFIED), + intval($register[0]['uid']) + ); - info( t('Account approved.') . EOL ); + info( t('Account verified. Please login.') . EOL ); + return true; } diff --git a/include/auth.php b/include/auth.php index e8f13d0fb..0baa80c2a 100644 --- a/include/auth.php +++ b/include/auth.php @@ -35,13 +35,18 @@ function nuke_session() { function account_verify_password($email,$pass) { + $email_verify = get_config('system','verify_email'); + + if($email_verify && $record['account_flags'] & ACCOUNT_UNVERIFIED) + return null; + $r = q("select * from account where account_email = '%s'", dbesc($email) ); if(! ($r && count($r))) return null; foreach($r as $record) { - if(($record['account_flags'] == ACCOUNT_OK) || ($record['account_flags'] == ACCOUNT_UNVERIFIED) + if(($record['account_flags'] == ACCOUNT_OK) && (hash('whirlpool',$record['account_salt'] . $pass) === $record['account_password'])) { logger('password verified for ' . $email); return $record; diff --git a/install/update.php b/install/update.php index bdf84144c..60e8497dc 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@