From 1a07aac836c93ec3726a8ce33ddc1010ea1ccaa0 Mon Sep 17 00:00:00 2001 From: Franzz Date: Sat, 11 Apr 2020 08:36:37 +0200 Subject: [PATCH] Log in when subscribing an existing email --- inc/user.php | 18 ++++++++++++++---- languages/en.lang | 2 +- languages/fr.lang | 2 +- masks/project.html | 9 ++------- readme.md | 3 ++- script/spot.js | 2 +- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/inc/user.php b/inc/user.php index 497b07f..8f55704 100644 --- a/inc/user.php +++ b/inc/user.php @@ -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'; diff --git a/languages/en.lang b/languages/en.lang index 232ba78..dff86c9 100644 --- a/languages/en.lang +++ b/languages/en.lang @@ -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 diff --git a/languages/fr.lang b/languages/fr.lang index 7ee7c51..09af20f 100644 --- a/languages/fr.lang +++ b/languages/fr.lang @@ -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 diff --git a/masks/project.html b/masks/project.html index 6d7fad8..3ff9ee1 100644 --- a/masks/project.html +++ b/masks/project.html @@ -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) { diff --git a/readme.md b/readme.md index 2bd43e8..f79cea7 100644 --- a/readme.md +++ b/readme.md @@ -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 \ No newline at end of file +* Subscribe to message feed +* Add mail frequency slider \ No newline at end of file diff --git a/script/spot.js b/script/spot.js index e535da3..144cb72 100755 --- a/script/spot.js +++ b/script/spot.js @@ -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) {