Ver Fonte

Add the ability to confirm your email address

Visman há 4 anos atrás
pai
commit
a401ce4d83

+ 1 - 1
app/Models/Pages/Profile/Edit.php

@@ -406,7 +406,7 @@ class Edit extends Profile
         if ($this->rules->editEmail) {
             $fields['change_email'] = [
                 'type'  => 'link',
-                'value' => __('To change email'),
+                'value' => __($this->rules->confirmEmail ? 'To confirm/change email' : 'To change email'),
                 'href'  => $this->c->Router->link(
                     'EditUserEmail',
                     [

+ 22 - 12
app/Models/Pages/Profile/Email.php

@@ -36,9 +36,13 @@ class Email extends Profile
         $this->user->email_confirmed = 1;
         $this->user->activate_string = '';
 
+        $change = $this->user->isModified('email');
+
         $this->c->users->update($this->user);
 
-        return $this->c->Redirect->url($this->user->link)->message('Email changed redirect');
+        return $this->c->Redirect
+            ->url($this->user->link)
+            ->message($change ? 'Email changed redirect' : 'Email confirmed redirect');
     }
 
     /**
@@ -78,20 +82,24 @@ class Email extends Profile
                 ]);
 
             if ($v->validation($_POST)) {
-                if ($v->new_email === $this->curUser->email) {
-                    return $this->c->Redirect->page('EditUserProfile', ['id' => $this->curUser->id])->message('Email is old redirect');
-                }
-
                 if (
-                    $this->user->isAdmin
-                    || '1' != $this->c->config->o_regs_verify
+                    $v->new_email === $this->curUser->email
+                    && ! $this->rules->confirmEmail
                 ) {
+                    return $this->c->Redirect
+                        ->page('EditUserProfile', ['id' => $this->curUser->id])
+                        ->message('Email is old redirect');
+                }
+
+                if (! $this->rules->my) { // админ сменил чужой адрес O_o
                     $this->curUser->email           = $v->new_email;
                     $this->curUser->email_confirmed = 0;
 
                     $this->c->users->update($this->curUser);
 
-                    return $this->c->Redirect->page('EditUserProfile', ['id' => $this->curUser->id])->message('Email changed redirect');
+                    return $this->c->Redirect
+                        ->page('EditUserProfile', ['id' => $this->curUser->id])
+                        ->message('Email changed redirect');
                 } else {
                     $key  = $this->c->Secury->randomPass(33);
                     $hash = $this->c->Secury->hash($this->curUser->id . $v->new_email . $key);
@@ -131,9 +139,11 @@ class Email extends Profile
 
                         $this->c->users->update($this->curUser);
 
-                        return $this->c->Message->message(__('Activate email sent', $this->c->config->o_admin_email), false, 200);
+                        return $this->c->Message
+                            ->message(__('Activate email sent', $this->c->config->o_admin_email), false, 200);
                     } else {
-                        return $this->c->Message->message(__('Error mail', $this->c->config->o_admin_email), true, 200);
+                        return $this->c->Message
+                            ->message(__('Error mail', $this->c->config->o_admin_email), true, 200);
                     }
                 }
             } else {
@@ -199,11 +209,11 @@ class Email extends Profile
                         'new_email' => [
                             'type'      => 'text',
                             'maxlength' => 80,
-                            'caption'   => __('New email'),
+                            'caption'   => __($this->rules->confirmEmail ? 'New or old email' : 'New email'),
                             'required'  => true,
                             'pattern'   => '.+@.+',
                             'value'     => $this->curUser->email,
-                            'info'      => ! $this->user->isAdmin && '1' == $this->c->config->o_regs_verify ? __('Email instructions') : null,
+                            'info'      => $this->rules->my ? __('Email instructions') : null,
                         ],
                         'password' => [
                             'type'      => 'password',

+ 5 - 0
app/Models/Rules/Profile.php

@@ -74,6 +74,11 @@ class Profile extends Rules
         return $this->my || $this->admin;
     }
 
+    protected function getconfirmEmail(): bool
+    {
+        return $this->my && ! $this->curUser->email_confirmed;
+    }
+
     protected function getsendEmail(): ?bool // ???? проверка на подтвержденный email?
     {
         if ($this->viewEmail) {

+ 0 - 3
app/lang/en/auth.po

@@ -45,9 +45,6 @@ msgstr "Remember me"
 msgid "Forget mail"
 msgstr "An email has been sent to the specified address with instructions on how to change your passphrase. If it does not arrive you can contact the forum administrator at <a href=\"mailto:%1$s\">%1$s</a>."
 
-msgid "Account email flood"
-msgstr "This account has already requested a passphrase reset recently. Please wait %s minutes before trying again."
-
 msgid "Pass not match"
 msgstr "Passphrases do not match."
 

+ 3 - 3
app/lang/en/mail/activate_email.tpl

@@ -1,10 +1,10 @@
-Subject: Change email address requested
+Subject: Activate email address requested
 
 Hello {!username!},
 
-You have requested to have a new email address assigned to your account in the discussion forum at {!fRootLink!}. If you didn't request this or if you don't want to change your email address you should just ignore this message. Only if you visit the activation page below will your email address be changed. In order for the activation page to work, you must be logged in to the forum.
+You have requested to activate this email address assigned to your account in the discussion forum at {!fRootLink!}. If you didn't request this or if you don't want to change/confirm your email address you should just ignore this message. Only if you visit the activation page below will your email address be changed. In order for the activation page to work, you must be logged in to the forum.
 
-To change your email address, please visit the following page: {!link!}
+To change/confirm your email address, please visit the following page: {!link!}
 
 --
 {!fMailer!} Mailer

+ 12 - 3
app/lang/en/profile.po

@@ -79,19 +79,22 @@ msgid "Email updated"
 msgstr "Your email address has been updated."
 
 msgid "Activate email sent"
-msgstr "An email has been sent to the specified address with instructions on how to activate the new email address. If it does not arrive you can contact the forum administrator at <a href=\"mailto:%1$s\">%1$s</a>."
+msgstr "An email has been sent to the specified address with instructions on how to activate the email address. If it does not arrive you can contact the forum administrator at <a href=\"mailto:%1$s\">%1$s</a>."
 
 msgid "Email legend"
 msgstr "Enter your new email address"
 
 msgid "Email instructions"
-msgstr "An email will be sent to your new address with an activation link. You must click the link in the email you receive to activate the new address."
+msgstr "An email with an activation link will be sent to this email address. You must click the link in the email you receive to activate this address."
 
 msgid "Change email"
 msgstr "Change email address"
 
 msgid "New email"
-msgstr "New email"
+msgstr "New email address"
+
+msgid "New or old email"
+msgstr "New or old (for confirmation) email address"
 
 msgid "Avatars disabled"
 msgstr "The administrator has disabled avatar support."
@@ -438,12 +441,18 @@ msgstr "Signature has only capital letters"
 msgid "To change email"
 msgstr "Change email address"
 
+msgid "To confirm/change email"
+msgstr "Confirm/change email address"
+
 msgid "Email is old redirect"
 msgstr "Email address is not changed. Redirecting …"
 
 msgid "Email changed redirect"
 msgstr "Email address changed. Redirecting …"
 
+msgid "Email confirmed redirect"
+msgstr "Email address confirmed. Redirecting …"
+
 msgid "Pass not match"
 msgstr "Passphrases do not match."
 

+ 3 - 0
app/lang/en/validator.po

@@ -41,3 +41,6 @@ msgstr "The username you entered is not unique. Please choose another username."
 
 msgid "Dupe email"
 msgstr "Someone else is already registered with that email address. Please choose another email address."
+
+msgid "Account email flood"
+msgstr "This account has already requested a passphrase reset recently. Please wait %s minutes before trying again."

+ 0 - 3
app/lang/ru/auth.po

@@ -45,9 +45,6 @@ msgstr "Запомнить меня"
 msgid "Forget mail"
 msgstr "Письмо с инструкцией по изменению кодовой фразы было выслано на указанный вами почтовый адрес. Если вы не получите его, свяжитесь с администрацией форума по адресу <a href=\"mailto:%1$s\">%1$s</a>."
 
-msgid "Account email flood"
-msgstr "Для этой учетной записи недавно уже запрашивали сброс кодовой фразы. Пожалуйста, подождите %s минут, прежде чем повторить попытку."
-
 msgid "Pass not match"
 msgstr "Кодовые фразы не совпадают."
 

+ 3 - 3
app/lang/ru/mail/activate_email.tpl

@@ -1,10 +1,10 @@
-Subject: Запрос на смену почтового адреса
+Subject: Запрос на активацию почтового адреса
 
 Здравствуйте, {!username!}.
 
-Кто-то, возможно вы, сделал запрос на смену почтового адреса аккаунта на форуме {!fRootLink!}. Если это не ваш запрос или вы передумали менять почтовый адрес аккаунта, то ни чего не делайте. Ваш почтовый адрес на форуме поменяется только, если вы посетите активационную ссылку. Чтобы активационная ссылка сработала, необходимо войти на форум под своими регистрационными данными.
+Кто-то, возможно вы, сделал запрос на активацию почтового адреса аккаунта на форуме {!fRootLink!}. Если это не ваш запрос или вы передумали, то ни чего не делайте. Ваш почтовый адрес на форуме изменится/будет подтвержден только, если вы посетите активационную ссылку. Чтобы активационная ссылка сработала, необходимо войти на форум под своими регистрационными данными.
 
-Чтобы сменить email адрес, вам нужно перейти по ссылке: {!link!}
+Чтобы сменить/подтвердить email адрес, вам нужно перейти по ссылке: {!link!}
 
 --
 Отправитель {!fMailer!}

+ 1 - 1
app/lang/ru/mail/form_email.tpl

@@ -2,7 +2,7 @@ Subject: {!mailSubject!}
 
 Здравствуйте, {!username!}.
 
-Пользователь '{!sender!}' с форума '{!fTitle!}' послал вам сообщение. Вы можете ответить '{!sender!}' напрямую на его e-mail, просто ответив на письмо.
+Пользователь '{!sender!}' с форума '{!fTitle!}' отправил вам сообщение. Вы можете ответить '{!sender!}' напрямую на его e-mail, просто ответив на это письмо.
 
 Само сообщение:
 -----------------------------------------------------------------------

+ 12 - 3
app/lang/ru/profile.po

@@ -79,19 +79,22 @@ msgid "Email updated"
 msgstr "Ваш почтовый адрес изменён."
 
 msgid "Activate email sent"
-msgstr "На указанный почтовый адрес было отправлено письмо с инструкциями по активации новой почты. Если вы не получите его, свяжитесь с администрацией форума по адресу <a href=\"mailto:%1$s\">%1$s</a>."
+msgstr "На указанный почтовый адрес было отправлено письмо с инструкциями по активации почтового адреса. Если вы не получите его, свяжитесь с администрацией форума по адресу <a href=\"mailto:%1$s\">%1$s</a>."
 
 msgid "Email legend"
 msgstr "Ввод нового почтового адреса"
 
 msgid "Email instructions"
-msgstr "На новый почтовый адрес будет отправлено письмо со ссылкой для активации. Вы должны будете перейти по ссылке, указанной в письме, для завершения процедуры изменения параметров."
+msgstr "На этот почтовый адрес будет отправлено письмо со ссылкой для активации. Вы должны будете перейти по ссылке, указанной в письме, для завершения процедуры изменения параметров."
 
 msgid "Change email"
 msgstr "Изменение адреса электронной почты"
 
 msgid "New email"
-msgstr "Новый email"
+msgstr "Новый адреса электронной почты"
+
+msgid "New or old email"
+msgstr "Новый или старый (для подтверждения) адрес электронной почты"
 
 msgid "Avatars disabled"
 msgstr "Администратор выключил использование аватар."
@@ -438,12 +441,18 @@ msgstr "Текст подписи содержит только заглавны
 msgid "To change email"
 msgstr "Изменить адрес электронной почты"
 
+msgid "To confirm/change email"
+msgstr "Подтвердить/изменить адрес электронной почты"
+
 msgid "Email is old redirect"
 msgstr "Адрес электронной почты оставлен без изменений. Переадресация &hellip;"
 
 msgid "Email changed redirect"
 msgstr "Адрес электронной почты изменен. Переадресация &hellip;"
 
+msgid "Email confirmed redirect"
+msgstr "Адрес электронной почты подтвержден. Переадресация &hellip;"
+
 msgid "Pass not match"
 msgstr "Кодовые фразы не совпадают."
 

+ 3 - 0
app/lang/ru/validator.po

@@ -41,3 +41,6 @@ msgstr "Выбранное имя пользователя не уникальн
 
 msgid "Dupe email"
 msgstr "Введенный почтовый адрес уже кем-то используется. Пожалуйста, выберите другой адрес."
+
+msgid "Account email flood"
+msgstr "Для этой учетной записи недавно уже запрашивали сброс кодовой фразы. Пожалуйста, подождите %s минут, прежде чем повторить попытку."