Fixed: Change E-Mail broken

This commit is contained in:
Lucas Bartholemy 2015-09-05 18:32:07 +02:00
parent f3ff457b54
commit 056ae54a15
3 changed files with 29 additions and 28 deletions

View File

@ -215,7 +215,7 @@ class AccountController extends Controller
{
$user = Yii::$app->user->getIdentity();
if ($user->auth_mode != User::AUTH_MODE_LOCAL) {
throw new CHttpException(500, Yii::t('UserModule.controllers_AccountController', 'You cannot change your e-mail address here.'));
throw new HttpException(500, Yii::t('UserModule.controllers_AccountController', 'You cannot change your e-mail address here.'));
}
$model = new \humhub\modules\user\models\forms\AccountChangeEmail;

View File

@ -21,6 +21,7 @@
namespace humhub\modules\user\models\forms;
use Yii;
use yii\helpers\Url;
use humhub\models\Setting;
/**
@ -67,21 +68,21 @@ class AccountChangeEmail extends \yii\base\Model
*/
public function sendChangeEmail()
{
$user = Yii::$app->user->getIdentity();
if ($this->validate()) {
$token = md5(Setting::Get('secret') . $user->guid . $this->newEmail);
$user = Yii::app()->user->getIdentity();
$token = md5(Setting::Get('secret') . $user->guid . $this->newEmail);
$message = new HMailMessage();
$message->view = "application.modules_core.user.views.mails.ChangeEmail";
$message->addFrom(Setting::Get('systemEmailAddress', 'mailing'), Setting::Get('systemEmailName', 'mailing'));
$message->addTo($this->newEmail);
$message->subject = Yii::t('UserModule.forms_AccountChangeEmailForm', 'E-Mail change');
$message->setBody(array('user' => $user, 'newEmail' => $this->newEmail, 'token' => $token), 'text/html');
Yii::app()->mail->send($message);
}
$mail = Yii::$app->mailer->compose(['html' => '@humhub/modules/user/views/mails/ChangeEmail'], [
'user' => $user,
'newEmail' => $this->newEmail,
'approveUrl' => Url::to(["/user/account/change-email-validate", 'email' => $this->newEmail, 'token' => $token], true)
]);
$mail->setFrom([\humhub\models\Setting::Get('systemEmailAddress', 'mailing') => \humhub\models\Setting::Get('systemEmailName', 'mailing')]);
$mail->setTo($this->newEmail);
$mail->setSubject(Yii::t('UserModule.forms_AccountChangeEmailForm', 'E-Mail change'));
$mail->send();
return true;
}
}

View File

@ -1,5 +1,7 @@
<?php $this->beginContent('application.views.mail.template'); ?>
<?php
use yii\helpers\Html;
?>
<tr>
<td align="center" valign="top" class="fix-box">
@ -25,9 +27,9 @@
<tr>
<td width="auto" align="center" valign="middle" height="28" style=" background-color:#ffffff; background-clip: padding-box; font-size:26px; font-family:Open Sans, Arial,Tahoma, Helvetica, sans-serif; text-align:center; color:#a3a2a2; font-weight: 300; padding-left:18px; padding-right:18px; ">
<span style="color: #555555; font-weight: 300;">
<?php echo Yii::t('UserModule.views_mails_ChangeEmail', '<strong>Confirm</strong></strong> your new email address'); ?>
</span>
<span style="color: #555555; font-weight: 300;">
<?php echo Yii::t('UserModule.views_mails_ChangeEmail', '<strong>Confirm</strong></strong> your new email address'); ?>
</span>
</td>
</tr>
</table>
@ -92,9 +94,9 @@
<tr>
<td style="font-size: 14px; line-height: 22px; font-family:Open Sans,Arial,Tahoma, Helvetica, sans-serif; color:#777777; font-weight:300; text-align:left; ">
<?php echo Yii::t('UserModule.views_mails_ChangeEmail', 'Hello'); ?> <?php echo CHtml::encode($user->displayName); ?>,<br><br>
<?php echo Yii::t('UserModule.views_mails_ChangeEmail', 'Hello'); ?> <?php echo Html::encode($user->displayName); ?>,<br><br>
<?php echo Yii::t('UserModule.views_mails_ChangeEmail', 'You have requested to change your e-mail address.<br>Your new e-mail address is {newemail}.<br><br>To confirm your new e-mail address please click on the button below.', array('{newemail}' => CHtml::encode($newEmail))); ?>
<?php echo Yii::t('UserModule.views_mails_ChangeEmail', 'You have requested to change your e-mail address.<br>Your new e-mail address is {newemail}.<br><br>To confirm your new e-mail address please click on the button below.', array('{newemail}' => Html::encode($newEmail))); ?>
</td>
</tr>
@ -119,11 +121,11 @@
<tr>
<td width="auto" align="center" valign="middle" height="32" style=" background-color:#7191a8; border-radius:5px; background-clip: padding-box;font-size:14px; font-family:Open Sans, Arial,Tahoma, Helvetica, sans-serif; text-align:center; color:#ffffff; font-weight: 600; padding-left:30px; padding-right:30px; padding-top: 5px; padding-bottom: 5px;">
<span style="color: #ffffff; font-weight: 300;">
<a href="<?php echo Yii::app()->createAbsoluteUrl("//user/account/changeEmailValidate", array('email'=>$newEmail, 'token'=>$token)); ?>" style="text-decoration: none; color: #ffffff; font-weight: 300;">
<strong><?php echo Yii::t('UserModule.views_mails_ChangeEmail', 'Confirm'); ?></strong>
</a>
</span>
<span style="color: #ffffff; font-weight: 300;">
<a href="<?php echo $approveUrl; ?>" style="text-decoration: none; color: #ffffff; font-weight: 300;">
<strong><?php echo Yii::t('UserModule.views_mails_ChangeEmail', 'Confirm'); ?></strong>
</a>
</span>
</td>
</tr>
@ -152,6 +154,4 @@
</table>
<!-- end container width 600px -->
</td>
</tr>
<?php $this->endContent(); ?>
</tr>