Log in when subscribing an existing email

This commit is contained in:
2020-04-11 08:36:37 +02:00
parent 3b28288f0c
commit 63d01a8543
6 changed files with 21 additions and 15 deletions

View File

@@ -38,16 +38,23 @@ class User extends PhpObject {
//Check Email availability
$iUserId = $this->oDb->selectValue(self::USER_TABLE, Db::getId(self::USER_TABLE), array('email'=>$sEmail, 'active'=>'1'));
if($iUserId > 0) $sDesc = 'lang:nl_email_exists';
if($iUserId > 0) {
//Log user in
$sDesc = 'lang:nl_email_exists';
$bSuccess = true;
}
else {
//Add/Reactivate user
$iUserId = $this->oDb->insertUpdateRow(self::USER_TABLE, array('email'=>$sEmail, 'language'=>$sLang, 'active'=>'1'), array('email'));
if($iUserId==0) $sDesc = 'lang:error_commit_db';
else $bSuccess = true;
else {
$sDesc = 'lang:nl_subscribed';
$bSuccess = true;
}
}
//Set Cookie (valid 1 year)
if($iUserId > 0) {
if($bSuccess) {
$this->setUserId($iUserId);
$this->updateCookie();
}
@@ -62,7 +69,10 @@ class User extends PhpObject {
if($this->iUserId > 0) {
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $this->iUserId, array('active'=>'0'));
if($iUserId==0) $sDesc = 'lang:error_commit_db';
else $bSuccess = true;
else {
$sDesc = 'lang:nl_unsubscribed';
$bSuccess = true;
}
}
else $sDesc = 'lang:nl_unknown_email';