Log in when subscribing an existing email

This commit is contained in:
2020-04-11 08:36:37 +02:00
parent abab8e1f22
commit 1a07aac836
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';

View File

@@ -71,7 +71,7 @@ newsletter = Keep in touch!
nl_email_placeholder= my@email.com
nl_subscribed_desc = You're all set. We'll send you updates as soon as we get them
nl_unsubscribed_desc= Write down your email address and we'll send you François' position as soon as we get it :)
nl_email_exists = This email is already subscribed
nl_email_exists = This email is already subscribed. You can unsubscribe by clicking on the button above.
nl_subscribe = Subscribe
nl_subscribed = Thanks! You'll receive a confirmation email shortly
nl_unsubscribe = Unsubscribe

View File

@@ -71,7 +71,7 @@ newsletter = Rester en contact
nl_email_placeholder= mon@email.com
nl_subscribed_desc = C'est tout bon. On t'enverra les nouvelles posititions dès qu'on les reçoit
nl_unsubscribed_desc= Ajoute ton adresse email et on t'enverra la nouvelle position de François dès qu'on la reçoit :)
nl_email_exists = Cette adresse email est déjà enregistrée
nl_email_exists = Cette adresse email est déjà enregistrée. Vous pouvez vous désinscrire en cliquant sur le bouton ci-dessus.
nl_subscribe = S'abonner
nl_subscribed = Merci ! Tu vas recevoir un email de confirmation très bientôt
nl_unsubscribe = Se désinscrire

View File

@@ -274,8 +274,8 @@ function initSettings(){
else {
oSpot.get(
sAction,
function(asData) {
settingsFeedback('success', oSpot.lang('nl_'+sAction+'d'));
function(asData, sDesc) {
settingsFeedback('success', sDesc);
oSpot.vars('user', asData);
setUserInterface();
},
@@ -306,15 +306,10 @@ function setUserInterface() {
if(asUserInfo.name) $('#name').val(asUserInfo.name);
}
else { //Unsubscribed User
//Switch to subcribe mode
$('#email').val('').prop('disabled', false);
$('#nl_btn').attr({name: 'subscribe', title: oSpot.lang('nl_subscribe'), 'class':'subscribe'});
$('#nl_desc').text(oSpot.lang('nl_unsubscribed_desc'));
//Reset nickname
$('#name').val('');
}
}
function onAutoUpdate(bFirstExec) {

View File

@@ -13,4 +13,5 @@
* Reset zoom on image closing (lightbox)
* Fix video fullscreen button on ios
* Fix lightbox portrait mode: push text under
* Subscribe to message feed
* Subscribe to message feed
* Add mail frequency slider

View File

@@ -86,7 +86,7 @@ function Spot(asGlobals)
if(oData.desc.substr(0, self.consts.lang_prefix.length)==self.consts.lang_prefix) oData.desc = self.lang(oData.desc.substr(5));
if(oData.result==self.consts.error) fOnError(oData.desc);
else fOnSuccess(oData.data);
else fOnSuccess(oData.data, oData.desc);
})
.fail(function(jqXHR, textStatus, errorThrown)
{