提交 a3f5f884 编写于 作者: R root

customer account reset password

上级 1ee30960
......@@ -21,9 +21,24 @@ return [
/* appfront base theme dir */
'appfrontBaseTheme' => '@fecshop/app/appfront/theme/base/front',
'appfrontBaseLayoutName'=> 'main.php',
'mailer' => [
# 用来发送邮件的函数helper类,用来处理数据,生成邮件内容,然后调用邮件service
# 通过配置的方式去访问调用的目的是为了让用户可以通过配置 重写这个类
'mailer_class' => 'fecshop\app\appfront\helper\mailer\Email',
#在邮件中显示的Store的名字
'storeName' => 'FecShop',
# 在邮件中显示的电话
'phone' => '11111111',
# 在邮件中显示的联系邮箱地址。
'contacts' => [
'emailAddress' => '2358269014@qq.com',
]
],
],
# language config.
# Yii组件配置
'components' => [
# language config.
'i18n' => [
'translations' => [
'appfront' => [
......
......@@ -15,10 +15,14 @@ return [
'successAutoLogin' => true,
# 注册登录成功后,跳转的url
'loginSuccessRedirectUrlKey' => 'customer/account',
# 注册页面的验证码是否开启
'registerPageCaptcha' => true,
# 注册账号后发送的邮件信息。
'email' => [
'enable' => true,
# 邮件内容的动态数据提供部分
'block' => 'fecshop\app\appfront\modules\Customer\block\mailer\account\register\EmailBody',
# 邮件内容的view部分
'viewPath' => 'mailer/customer/account/register',
'mailerConfig' => [
......@@ -26,9 +30,9 @@ return [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.sendgrid.net',
'username' => 'support@onfancymail.com',
'password' => 'check301',
'host' => 'smtp.qq.com',
'username' => '2358269014@qq.com',
'password' => 'bjxpkyzfwkxnebai',
'port' => '587',
'encryption' => 'tls',
],
......@@ -44,16 +48,29 @@ return [
'loginPageSuccessRedirectUrlKey' => 'customer/account',
# 在其他页面的弹框方式登录的账号成功后,的页面跳转,如果是false,则代表返回原来的页面。
'otherPageSuccessRedirectUrlKey' => false ,
'loginPageCaptcha' => true, // 登录验证码是否开启
# 登录页面的验证码是否开启
'loginPageCaptcha' => false,
# 邮件信息,登录账号后是否发送邮件
'email' => [
'enable' => true,
# 邮件内容的动态数据提供部分
'block' => 'fecshop\app\appfront\modules\Customer\block\mailer\account\login\EmailBody',
# 邮件内容的view部分
'viewPath' => 'mailer/customer/account/login',
# 如果不定义 mailerConfig,则会使用email service里面的默认配置
]
],
'forgotPassword' => [
'forgotCaptcha' => true,
'email' => [
'block' => 'fecshop\app\appfront\modules\Customer\block\mailer\account\forgotpassword\EmailBody',
# 邮件内容的view部分
'viewPath' => 'mailer/customer/account/forgotpassword',
# 如果不定义 mailerConfig,则会使用email service里面的默认配置
//'mailerConfig' => []
],
],
],
],
];
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\helper\mailer;
use Yii;
use fec\helpers\CConfig;
use fec\controllers\FecController;
use yii\base\InvalidValueException;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Email
{
/**
* 得到联系我们的邮箱地址
*/
public static function contactsEmailAddress(){
$mailerConfig = Yii::$app->params['mailer'];
if(isset($mailerConfig['contacts']['emailAddress'])){
return $mailerConfig['contacts']['emailAddress'];
}
}
/**
* 得到Store Name
*/
public static function storeName(){
$mailerConfig = Yii::$app->params['mailer'];
if(isset($mailerConfig['storeName'])){
return $mailerConfig['storeName'];
}
}
public static function contactsPhone(){
$mailerConfig = Yii::$app->params['mailer'];
if(isset($mailerConfig['phone'])){
return $mailerConfig['phone'];
}
}
/**
* 通过block 和 view 得到邮件内容
*/
public static function getSubjectAndBody($block,$viewPath,$langCode='',$params=[]){
if(!$langCode){
$langCode = Yii::$service->store->currentLangCode;
}
if(!$langCode){
Yii::$service->helper->errors->add('langCode is empty');
return ;
}
$bodyViewFile = $viewPath.'/body_'.$langCode.'.php';
$bodyConfigKey = [
'class' => $block,
'view' => $bodyViewFile,
];
if(!empty($params)){
$bodyConfigKey['params'] = $params;
}
$subjectViewFile = $viewPath.'/subject_'.$langCode.'.php';
$subjectConfigKey = [
'class' => $block,
'view' => $subjectViewFile,
];
$emailSubject = Yii::$service->page->widget->render($subjectConfigKey,$parentThis);
$emailBody = Yii::$service->page->widget->render($bodyConfigKey,$parentThis);
return [$emailSubject,$emailBody];
}
/**
* @property $toEmail | String send to email address.
* 客户注册用户发送邮件
*/
public static function sendRegisterEmail($param){
$toEmail = $param['email'];
$registerParam = Yii::$app->getModule('customer')->params['register'];
if(isset($registerParam['email']['enable']) && $registerParam['email']['enable']){
$mailerConfigParam = '';
if(isset($registerParam['email']['mailerConfig']) && $registerParam['email']['mailerConfig']){
$mailerConfigParam = $registerParam['email']['mailerConfig'];
}
if(isset($registerParam['email']['block']) && $registerParam['email']['block']){
$block = $registerParam['email']['block'];
}
if(isset($registerParam['email']['viewPath']) && $registerParam['email']['viewPath']){
$viewPath = $registerParam['email']['viewPath'];
}
if($block && $viewPath){
list($subject,$htmlBody) = self::getSubjectAndBody($block,$viewPath,'',$param);
$sendInfo = [
'to' => $toEmail,
'subject' => $subject,
'htmlBody' => $htmlBody,
'senderName'=> Yii::$service->store->currentStore,
];
//var_dump($sendInfo);exit;
Yii::$service->email->send($sendInfo,$mailerConfigParam);
}
}
}
/**
* 客户登录账号发送邮件
*/
public static function sendLoginEmail($toEmail){
$registerParam = Yii::$app->getModule('customer')->params['login'];
if(isset($registerParam['email']['enable']) && $registerParam['email']['enable']){
$mailerConfigParam = '';
if(isset($registerParam['email']['mailerConfig']) && $registerParam['email']['mailerConfig']){
$mailerConfigParam = $registerParam['email']['mailerConfig'];
}
if(isset($registerParam['email']['block']) && $registerParam['email']['block']){
$block = $registerParam['email']['block'];
}
if(isset($registerParam['email']['viewPath']) && $registerParam['email']['viewPath']){
$viewPath = $registerParam['email']['viewPath'];
}
if($block && $viewPath){
list($subject,$htmlBody) = self::getSubjectAndBody($block,$viewPath);
$sendInfo = [
'to' => $toEmail,
'subject' => $subject,
'htmlBody' => $htmlBody,
'senderName'=> Yii::$service->store->currentStore,
];
Yii::$service->email->send($sendInfo,$mailerConfigParam);
}
}
}
/**
* 客户登录账号发送邮件
*/
public static function sendForgotPasswordEmail($param){
$toEmail = $param['email'];
$forgotPasswordParam = Yii::$app->getModule('customer')->params['forgotPassword'];
$mailerConfigParam = '';
if(isset($forgotPasswordParam['email']['mailerConfig']) && $forgotPasswordParam['email']['mailerConfig']){
$mailerConfigParam = $forgotPasswordParam['email']['mailerConfig'];
}
if(isset($forgotPasswordParam['email']['block']) && $forgotPasswordParam['email']['block']){
$block = $forgotPasswordParam['email']['block'];
}
if(isset($forgotPasswordParam['email']['viewPath']) && $forgotPasswordParam['email']['viewPath']){
$viewPath = $forgotPasswordParam['email']['viewPath'];
}
if($block && $viewPath){
list($subject,$htmlBody) = self::getSubjectAndBody($block,$viewPath,'',$param);
$sendInfo = [
'to' => $toEmail,
'subject' => $subject,
'htmlBody' => $htmlBody,
'senderName'=> Yii::$service->store->currentStore,
];
//var_dump($sendInfo);exit;
Yii::$service->email->send($sendInfo,$mailerConfigParam);
}
}
}
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\modules\Customer\block\account;
use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use yii\base\InvalidValueException;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Forgotpassword {
public function getLastData(){
$forgotPasswordParam = \Yii::$app->getModule('customer')->params['forgotPassword'];
$forgotCaptcha = isset($forgotPasswordParam['forgotCaptcha']) ? $forgotPasswordParam['forgotCaptcha'] : false;
return [
'forgotCaptcha' => $forgotCaptcha,
];
}
public function sendForgotPasswordMailer($editForm){
$captcha = $editForm['captcha'];
$forgotPasswordParam = \Yii::$app->getModule('customer')->params['forgotPassword'];
$forgotCaptcha = isset($forgotPasswordParam['forgotCaptcha']) ? $forgotPasswordParam['forgotCaptcha'] : false;
# 如果开启了验证码,但是验证码验证不正确就报错返回。
if($forgotCaptcha && !$captcha){
Yii::$service->page->message->addError(['Captcha can not empty']);
return;
}else if($captcha && $forgotCaptcha && !\Yii::$service->helper->captcha->validateCaptcha($captcha)){
Yii::$service->page->message->addError(['Captcha is not right']);
return;
}
#判断该邮箱是否存在
if($identity = $this->getUserIdentity($editForm)){
# 生成重置密码的 passwordResetToken
$passwordResetToken = Yii::$service->customer->generatePasswordResetToken($identity);
if($passwordResetToken){
$identity['password_reset_token'] = $passwordResetToken;
$this->sendForgotPasswordEmail($identity);
return $identity;
}
}else{
Yii::$service->page->message->addError(['email is not exist']);
return;
}
}
/**
* 发送忘记密码邮件
*/
public function sendForgotPasswordEmail($identity){
if($identity){
$mailerConfig = Yii::$app->params['mailer'];
$mailer_class = isset($mailerConfig['mailer_class']) ? $mailerConfig['mailer_class'] : '';
if($mailer_class){
forward_static_call(
[$mailer_class , 'sendForgotPasswordEmail'],
$identity
);
}
}
}
public function getUserIdentity($editForm){
$email = $editForm['email'];
if($email){
$identity = Yii::$service->customer->getUserIdentityByEmail($email);
if($identity){
return $identity;
}
}
return false;
}
}
......@@ -11,12 +11,14 @@ use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use yii\base\InvalidValueException;
use fecshop\app\appfront\helper\mailer\Email;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Login {
public function getLastData(){
$loginParam = \Yii::$app->getModule('customer')->params['login'];
$loginPageCaptcha = isset($loginParam['loginPageCaptcha']) ? $loginParam['loginPageCaptcha'] : false;
......@@ -25,18 +27,23 @@ class Login {
];
}
public function login($param){
$captcha = $param['captcha'];
$loginParam = \Yii::$app->getModule('customer')->params['login'];
$loginPageCaptcha = isset($loginParam['loginPageCaptcha']) ? $loginParam['loginPageCaptcha'] : false;
if($captcha && $loginPageCaptcha && !\Yii::$service->helper->captcha->validateCaptcha($captcha)){
if($loginPageCaptcha && !$captcha){
Yii::$service->page->message->addError(['Captcha can not empty']);
return;
}else if($captcha && $loginPageCaptcha && !\Yii::$service->helper->captcha->validateCaptcha($captcha)){
Yii::$service->page->message->addError(['Captcha is not right']);
return;
}
if(is_array($param) && !empty($param)){
Yii::$service->customer->login($param);
# 发送邮件
if($param['email']){
$this->sendLoginEmail($param['email']);
}
}
if(!Yii::$app->user->isGuest){
Yii::$service->url->redirectByUrlKey('customer/account');
......@@ -55,4 +62,19 @@ class Login {
}
}
}
/**
* 发送登录邮件
*/
public function sendLoginEmail($emailAddress){
if($emailAddress){
$mailerConfig = Yii::$app->params['mailer'];
$mailer_class = isset($mailerConfig['mailer_class']) ? $mailerConfig['mailer_class'] : '';
if($mailer_class){
forward_static_call(
[$mailer_class , 'sendLoginEmail'],
$emailAddress
);
}
}
}
}
\ No newline at end of file
......@@ -43,12 +43,16 @@ class Register {
$registerParam = \Yii::$app->getModule('customer')->params['register'];
$registerPageCaptcha = isset($registerParam['registerPageCaptcha']) ? $registerParam['registerPageCaptcha'] : false;
# 如果开启了验证码,但是验证码验证不正确就报错返回。
if($captcha && $registerPageCaptcha && !\Yii::$service->helper->captcha->validateCaptcha($captcha)){
if($registerPageCaptcha && !$captcha){
Yii::$service->page->message->addError(['Captcha can not empty']);
return;
}else if($captcha && $registerPageCaptcha && !\Yii::$service->helper->captcha->validateCaptcha($captcha)){
Yii::$service->page->message->addError(['Captcha is not right']);
return;
}
Yii::$service->customer->register($param);
$errors = Yii::$service->helper->errors->get(true);
if($errors){
if(is_array($errors) && !empty($errors)){
......@@ -61,9 +65,27 @@ class Register {
}
}
}else{
# 发送注册邮件
$this->sendRegisterEmail($param);
return true;
}
}
/**
* 发送登录邮件
*/
public function sendRegisterEmail($param){
if($param){
$mailerConfig = Yii::$app->params['mailer'];
$mailer_class = isset($mailerConfig['mailer_class']) ? $mailerConfig['mailer_class'] : '';
if($mailer_class){
forward_static_call(
[$mailer_class , 'sendRegisterEmail'],
$param
);
}
}
}
}
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\modules\Customer\block\mailer\account\forgotpassword;
use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use yii\base\InvalidValueException;
use fecshop\app\appfront\helper\mailer\Email;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class EmailBody {
public $params;
public function getLastData(){
$identity = $this->params;
$resetUrl = Yii::$service->url->getUrl('customer/account/resetpassword',['resetToken'=>$identity['password_reset_token']]);
//echo $resetUrl;
//exit;
//echo Yii::$service->image->getImgUrl('mail/logo.png','appfront');exit;
return [
'name' => $identity['firstname'].' '. $identity['lastname'],
'email' => $identity['email'],
'resetUrl' => $resetUrl,
'storeName' => Email::storeName(),
'contactsEmailAddress' => Email::contactsEmailAddress(),
'contactsPhone' => Email::contactsPhone(),
'homeUrl' => Yii::$service->url->homeUrl(),
'logoImg' => Yii::$service->image->getImgUrl('mail/logo.png','appfront'),
//'loginUrl' => Yii::$service->url->getUrl("customer/account/index"),
//'accountUrl'=> Yii::$service->url->getUrl("customer/account/index"),
'identity' => $identity,
];
}
}
\ No newline at end of file
......@@ -11,14 +11,32 @@ use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use yii\base\InvalidValueException;
use fecshop\app\appfront\helper\mailer\Email;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class EmailBody {
public $params;
public function getLastData(){
return [];
$identity = Yii::$app->user->identity;
//echo Yii::$service->image->getImgUrl('mail/logo.png','appfront');exit;
return [
'name' => $identity['firstname'].' '. $identity['lastname'],
'email' => $identity['email'],
'password' => 'xxx',
'storeName' => Email::storeName(),
'contactsEmailAddress' => Email::contactsEmailAddress(),
'contactsPhone' => Email::contactsPhone(),
'homeUrl' => Yii::$service->url->homeUrl(),
'logoImg' => Yii::$service->image->getImgUrl('mail/logo.png','appfront'),
'loginUrl' => Yii::$service->url->getUrl("customer/account/index"),
'accountUrl'=> Yii::$service->url->getUrl("customer/account/index"),
'identity' => $identity,
];
}
......
......@@ -11,14 +11,33 @@ use Yii;
use fec\helpers\CModule;
use fec\helpers\CRequest;
use yii\base\InvalidValueException;
use fecshop\app\appfront\helper\mailer\Email;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class EmailBody {
public $params;
public function getLastData(){
return [];
$identity = $this->params;
//echo Yii::$service->image->getImgUrl('mail/logo.png','appfront');exit;
return [
'name' => $identity['firstname'].' '. $identity['lastname'],
'email' => $identity['email'],
'password' => $identity['password'],
'storeName' => Email::storeName(),
'contactsEmailAddress' => Email::contactsEmailAddress(),
'contactsPhone' => Email::contactsPhone(),
'homeUrl' => Yii::$service->url->homeUrl(),
'logoImg' => Yii::$service->image->getImgUrl('mail/logo.png','appfront'),
'loginUrl' => Yii::$service->url->getUrl("customer/account/index"),
'accountUrl'=> Yii::$service->url->getUrl("customer/account/index"),
'identity' => $identity,
];
}
......
......@@ -22,14 +22,21 @@ class AccountController extends AppfrontController
public function init(){
parent::init();
}
/**
* 账户中心
*/
public function actionIndex(){
if(Yii::$app->user->isGuest){
Yii::$service->url->redirectByUrlKey('customer/account/login');
}
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
}
/**
* 登录
*/
public function actionLogin()
{
/**
......@@ -39,20 +46,17 @@ class AccountController extends AppfrontController
exit;
*/
$param = Yii::$app->request->post('editForm');
$this->getBlock()->login($param);
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
}
/**
* 注册
*/
public function actionRegister()
{
$param = Yii::$app->request->post('editForm');
if(!empty($param)){
$registerStatus = $this->getBlock()->register($param);
//echo $registerStatus;exit;
......@@ -73,15 +77,14 @@ class AccountController extends AppfrontController
return $this->render($this->action->id,$data);
}
/**
* 登出账户
*/
public function actionLogout(){
$rt = Yii::$app->request->get('rt');
if(!Yii::$app->user->isGuest){
Yii::$app->user->logout();
}
Yii::$app->user->logout();
}
if($rt){
$redirectUrl = base64_decode($rt);
//exit;
......@@ -90,13 +93,51 @@ class AccountController extends AppfrontController
Yii::$service->url->redirect(Yii::$service->url->HomeUrl());
}
}
/**
* ajax 请求 ,得到是否登录账户的信息
*/
public function actionLogininfo(){
if(!Yii::$app->user->isGuest){
return json_encode([
echo json_encode([
'loginStatus' => true,
]);
exit;
}
}
/**
* 忘记密码?
*/
public function actionForgotpassword(){
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
}
public function actionForgotpasswordsubmit(){
$editForm = Yii::$app->request->post('editForm');
$data = [
'forgotPasswordUrl' => Yii::$service->url->getUrl('customer/account/forgotpassword'),
'contactUrl' => Yii::$service->url->getUrl('contacts/index/index'),
];
if(!empty($editForm)){
$identity = $this->getBlock('forgotpassword')->sendForgotPasswordMailer($editForm);
//var_dump($identity);
if($identity){
$data['identity'] = $identity;
}else{
$redirectUrl = Yii::$service->url->getUrl('customer/account/forgotpassword');
Yii::$service->url->redirect($redirectUrl);
}
}
return $this->render($this->action->id,$data);
}
public function actionResetpassword(){
$resetToken = Yii::$app->request->get('resetToken');
echo $resetToken;
}
}
......
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace fecshop\app\appfront\modules\Mailer;
use Yii;
use fec\helpers\CConfig;
use fec\controllers\FecController;
use yii\base\InvalidValueException;
/**
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class Email
{
public static function getSubjectAndBody($block,$viewPath,$langCode=''){
if(!$langCode){
$langCode = Yii::$service->store->currentLangCode;
}
if(!$langCode){
Yii::$service->helper->errors->add('langCode is empty');
return ;
}
$bodyViewFile = $viewPath.'/body_'.$langCode.'.php';
$bodyConfigKey = [
'class' => $block,
'view' => $bodyViewFile,
];
$subjectViewFile = $viewPath.'/subject_'.$langCode.'.php';
$subjectConfigKey = [
'view' => $subjectViewFile,
];
$emailSubject = Yii::$service->page->widget->render($subjectConfigKey);
$emailBody = Yii::$service->page->widget->render($bodyConfigKey);
return [$emailSubject,$emailBody];
}
/**
* @property $toEmail | String send to email address.
*
*/
public static function sendRegisterEmail($toEmail){
$registerParam = Yii::$app->getModule('customer')->params['register'];
if(isset($registerParam['email']['enable']) && $registerParam['email']['enable']){
$mailerConfigParam = '';
if(isset($registerParam['email']['mailerConfig']) && $registerParam['email']['mailerConfig']){
$mailerConfigParam = $registerParam['email']['mailerConfig'];
}
if(isset($registerParam['email']['block']) && $registerParam['email']['block']){
$block = $registerParam['email']['block'];
}
if(isset($registerParam['email']['viewPath']) && $registerParam['email']['viewPath']){
$viewPath = $registerParam['email']['viewPath'];
}
if($block && $viewPath){
list($subject,$htmlBody) = \fecshop\app\appfront\modules\Mailer\Email::getSubjectAndBody($block,$viewPath);
Yii::$service->email->send($toEmail,$subject,$htmlBody,$mailerConfigParam);
}
}
}
public static function sendLoginEmail($toEmail){
$registerParam = Yii::$app->getModule('customer')->params['login'];
if(isset($registerParam['email']['enable']) && $registerParam['email']['enable']){
$mailerConfigParam = '';
if(isset($registerParam['email']['mailerConfig']) && $registerParam['email']['mailerConfig']){
$mailerConfigParam = $registerParam['email']['mailerConfig'];
}
if(isset($registerParam['email']['block']) && $registerParam['email']['block']){
$block = $registerParam['email']['block'];
}
if(isset($registerParam['email']['viewPath']) && $registerParam['email']['viewPath']){
$viewPath = $registerParam['email']['viewPath'];
}
if($block && $viewPath){
list($subject,$htmlBody) = \fecshop\app\appfront\modules\Mailer\Email::getSubjectAndBody($block,$viewPath);
Yii::$service->email->send($toEmail,$subject,$htmlBody,$mailerConfigParam);
}
}
}
}
......@@ -1054,6 +1054,11 @@ button.redBtn:hover span{
padding: 0 0 0 10px;
width: 90px;
}
.forgot-captha{width:276px;}
.account-create form .forgot-captha input ,
.account-create form .forgot-captha img,
.account-create form .forgot-captha i{
margin-bottom:13px;
}
<div class="main container one-column">
<?= Yii::$service->page->widget->render('flashmessage'); ?>
<div class="account-create">
<div class="page-title">
<h1>Forgot Password</h1>
</div>
<form action="<?= Yii::$service->url->getUrl('customer/account/forgotpasswordsubmit'); ?>" method="post" id="form-validate">
<div class="fieldset" style="width:auto">
<h2 class="legend">Confirm your identity to reset password</h2>
<ul class="form-list">
<li>
<label for="email_address" class="required"><em>*</em>Email Address</label>
<div class="input-box">
<input name="editForm[email]" id="email_address" value="<?= $email ?>" title="Email Address" class="input-text validate-email required-entry" type="text">
</div>
</li>
<?php if($forgotCaptcha){ ?>
<li>
<div class="field">
<label for="captcha" class="required"><em>*</em>Captcha</label>
<div class="input-box forgot-captha register-captcha ">
<input type="text" name="editForm[captcha]" value="" size=10 class="login-captcha-input required-entry">
<img class="login-captcha-img" title="click refresh" src="<?= Yii::$service->url->getUrl('site/helper/captcha'); ?>" align="absbottom" onclick="this.src='<?= Yii::$service->url->getUrl('site/helper/captcha'); ?>?'+Math.random();"></img>
<i class="refresh-icon"></i>
<div class="clear"></div>
</div>
<script>
<?php $this->beginBlock('forgot_password_captcha_onclick_refulsh') ?>
$(document).ready(function(){
$(".refresh-icon").click(function(){
$(this).parent().find("img").click();
});
});
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['forgot_password_captcha_onclick_refulsh'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
</div>
</li>
<?php } ?>
</ul>
</div>
<?= \fec\helpers\CRequest::getCsrfInputHtml(); ?>
<div class="buttons-set">
<p class="required">* Required Fields</p>
<button type="button" id="js_registBtn" class="redBtn"><em><span><i></i>Submit</span></em></button>
<p class="back-link"><a href="<?= Yii::$service->url->getUrl('customer/account/login'); ?>" class="back-link"><small>« </small>Back</a></p>
</div>
<div class="clear"></div>
</form>
</div>
</div>
<?php
$requiredValidate = 'This is a required field.';
$emailFormatValidate = 'Please enter a valid email address. For example johndoe@domain.com.';
?>
<script>
<?php $this->beginBlock('forgot_password') ?>
$(document).ready(function(){
$("#js_registBtn").click(function(){
validate = 1;
$(".validation-advice").remove();
$(".validation-failed").removeClass("validation-failed");
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
// empty check
$(".account-create .required-entry").each(function(){
val = $(this).val();
if(!val){
$(this).addClass("validation-failed");
$(this).parent().append('<div class="validation-advice" id="advice-required-entry-firstname" style=""><?= $requiredValidate; ?></div>');
validate = 0;
}
});
// email check
$(".account-create .validate-email").each(function(){
email = $(this).val();
if(email){
if(!$(this).hasClass("validation-failed")){
if(!myreg.test(email)){
$(this).parent().append('<div class="validation-advice" id="advice-validate-email-email_address" style=""><?= $emailFormatValidate; ?></div>');
$(this).addClass("validation-failed");
validate = 0;
}
}
}else{
validate = 0;
}
});
if(validate){
$(this).addClass("dataUp");
$("#form-validate").submit();
}
});
});
<?php $this->endBlock(); ?>
</script>
<?php $this->registerJs($this->blocks['forgot_password'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
<div class="main container one-column">
<?php if(!empty($identity)){ ?>
<div>
We've sent a message to the email address <?= $identity['email'] ?>
you have on file with us.
Please follow the instructions provided in the message to reset your password.
</div>
<div>
<p>Didn't receive the mail from us? <a href="<?= $forgotPasswordUrl ?>">click here to retry</a></p>
<p>Check your bulk or junk email folder.</p>
<p>If you still can't find it, click <a href="<?= $contactUrl ; ?>">support center</a> for help </p>
</div>
<?php }else{ ?>
<div>
Email address do not exist, please <a href="<?= $forgotPasswordUrl ?>">click here</a> to re-enter!
</div>
<div>
<?php } ?>
</div>
\ No newline at end of file
......@@ -62,7 +62,7 @@
<label for="captcha" class="required"><em>*</em>Captcha</label>
<div class="input-box register-captcha">
<input type="text" name="editForm[captcha]" value="" size=10 class="login-captcha-input">
<img class="login-captcha-img" title="点击刷新" src="<?= Yii::$service->url->getUrl('site/helper/captcha'); ?>" align="absbottom" onclick="this.src='<?= Yii::$service->url->getUrl('site/helper/captcha'); ?>?'+Math.random();"></img>
<img class="login-captcha-img" title="click refresh" src="<?= Yii::$service->url->getUrl('site/helper/captcha'); ?>" align="absbottom" onclick="this.src='<?= Yii::$service->url->getUrl('site/helper/captcha'); ?>?'+Math.random();"></img>
<i class="refresh-icon"></i>
</div>
<script>
......@@ -150,10 +150,10 @@ $(document).ready(function(){
lastname = $("#lastname").val();
password = $("#password").val();
confirmation= $("#confirmation").val();
minNameLength = <?= $minNameLength ?>;
maxNameLength = <?= $maxNameLength ?>;
minPassLength = <?= $minPassLength ?>;
maxPassLength = <?= $maxPassLength ?>;
minNameLength = <?= $minNameLength ? $minNameLength : 4 ?>;
maxNameLength = <?= $maxNameLength ? $maxNameLength : 30 ?>;
minPassLength = <?= $minPassLength ? $minPassLength : 4 ?>;
maxPassLength = <?= $maxPassLength ? $maxPassLength : 30 ?>;
firstNameLength = firstname.length;
lastNameLength = lastname.length;
passwordLength = password.length;
......
<body style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;">
<div style="background: #F6F6F6; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; margin: 0; padding: 0;">
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
<tr>
<td align="center" valign="top" style="padding: 20px 0 20px 0">
<table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<tr>
<td valign="top">
<a href="<?= $homeUrl; ?>">
<img src="<?= $logoImg; ?>" alt="" style="margin:10px 0 ;" border="0"/>
</a>
</td>
</tr>
<tr>
<td valign="top">
<h1 style="font-size: 22px; font-weight: normal; line-height: 22px; margin: 0 0 11px 0;">Dear <?= $name ?>,</h1>
<p style="font-size: 12px; line-height: 16px; margin: 0 0 8px 0;">There was recently a request to change the password for your account.</p>
<p style="font-size: 12px; line-height: 16px; margin: 0 0 8px 0;">If you requested this password change, please click on the following link to reset your password: <a href="<?= $resetUrl ?>" style="color:#1E7EC8;"><?= $resetUrl ?></a></p>
<p style="font-size: 12px; line-height: 16px; margin: 0 0 4px 0;">If clicking the link does not work, please copy and paste the URL into your browser instead.</p>
<br />
<p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">If you did not make this request, you can ignore this message and your password will remain the same.</p>
<p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:<?= $contactsEmailAddress ?>" style="color:#1E7EC8;"><?= $contactsEmailAddress ?></a> or by phone at <?= $contactsPhone ?>.</p>
</td>
</tr>
<tr>
<td style="background-color: #EAEAEA; text-align: center;"><p style="font-size:12px; margin:0; text-align: center;">Thank you, <strong><?= $storeName; ?></strong></p></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
\ No newline at end of file
login body en
\ No newline at end of file
<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
<tr>
<td align="center" valign="top" style="padding:20px 0 20px 0">
<!-- [ header starts here] -->
<table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<tr>
<td valign="top">
<a href="<?= $homeUrl; ?>">
<img src="<?= $logoImg; ?>" alt="" style="margin:10px 0 ;" border="0"/>
</a>
</td>
</tr>
<!-- [ middle starts here] -->
<tr>
<td valign="top">
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear <?= $name ?>,</h1>
<p style="font-size:12px; line-height:16px; margin:0 0 16px 0;">Welcome to <?= $storeName ?>. To log in when visiting our site just click <a href="<?= $loginUrl ?>" style="color:#1E7EC8;">Login</a> or <a href="<?= $accountUrl ?>" style="color:#1E7EC8;">My Account</a> at the top of every page, and then enter your e-mail address and password.</p>
<p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">
Use the following values when prompted to log in:<br/>
<strong>E-mail</strong>: <?= $email; ?><br/>
<strong>Password</strong>: <?= $password; ?><p>
<p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">When you log in to your account, you will be able to do the following:</p>
<ul style="font-size:12px; line-height:16px; margin:0 0 16px 0; padding:0;">
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Proceed through checkout faster when making a purchase</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Check the status of orders</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; View past orders</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Make changes to your account information</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Change your password</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Store alternative addresses (for shipping to multiple family members and friends!)</li>
</ul>
<p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:<?= $contactsEmailAddress ?>" style="color:#1E7EC8;"><?= $contactsEmailAddress ?></a> or by phone at <?= $contactsPhone ?>.</p>
</td>
</tr>
<tr>
<td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong><?= $storeName; ?></strong></p></center></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
\ No newline at end of file
login subject en
\ No newline at end of file
you hava login your account on fecsop!
\ No newline at end of file
register body en
\ No newline at end of file
<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
<tr>
<td align="center" valign="top" style="padding:20px 0 20px 0">
<!-- [ header starts here] -->
<table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
<tr>
<td valign="top">
<a href="<?= $homeUrl; ?>">
<img src="<?= $logoImg; ?>" alt="" style="margin:10px 0 ;" border="0"/>
</a>
</td>
</tr>
<!-- [ middle starts here] -->
<tr>
<td valign="top">
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Dear <?= $name ?>,</h1>
<p style="font-size:12px; line-height:16px; margin:0 0 16px 0;">Welcome to <?= $storeName ?>. To log in when visiting our site just click <a href="<?= $loginUrl ?>" style="color:#1E7EC8;">Login</a> or <a href="<?= $accountUrl ?>" style="color:#1E7EC8;">My Account</a> at the top of every page, and then enter your e-mail address and password.</p>
<p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">
Use the following values when prompted to log in:<br/>
<strong>E-mail</strong>: <?= $email; ?><br/>
<strong>Password</strong>: <?= $password; ?><p>
<p style="font-size:12px; line-height:16px; margin:0 0 8px 0;">When you log in to your account, you will be able to do the following:</p>
<ul style="font-size:12px; line-height:16px; margin:0 0 16px 0; padding:0;">
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Proceed through checkout faster when making a purchase</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Check the status of orders</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; View past orders</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Make changes to your account information</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Change your password</li>
<li style="list-style:none inside; padding:0 0 0 10px;">&ndash; Store alternative addresses (for shipping to multiple family members and friends!)</li>
</ul>
<p style="font-size:12px; line-height:16px; margin:0;">If you have any questions about your account or any other matter, please feel free to contact us at <a href="mailto:<?= $contactsEmailAddress ?>" style="color:#1E7EC8;"><?= $contactsEmailAddress ?></a> or by phone at <?= $contactsPhone ?>.</p>
</td>
</tr>
<tr>
<td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong><?= $storeName; ?></strong></p></center></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
\ No newline at end of file
register subject en
\ No newline at end of file
you hava register account on fecsop!
\ No newline at end of file
......@@ -14,9 +14,9 @@ return [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.sendgrid.net',
'username' => 'support@onfancymail.com',
'password' => 'check301',
'host' => 'smtp.qq.com',
'username' => '2358269014@qq.com',
'password' => 'bjxpkyzfwkxnebai',
'port' => '587',
'encryption' => 'tls',
],
......
......@@ -42,7 +42,7 @@ return [
],
'captcha' => [
'class' => 'fecshop\services\helper\Captcha',
//'charset' => '0123456789', //随机因子
'charset' => '023456789', //随机因子
'codelen' => 4, //验证码长度
'width' => 130,//宽度
'height' => 50, //高度
......
......@@ -12,6 +12,7 @@ use yii\base\InvalidValueException;
use yii\base\InvalidConfigException;
use fecshop\models\mysqldb\customer\CustomerRegister;
use fecshop\models\mysqldb\customer\CustomerLogin;
use fecshop\models\mysqldb\Customer as CustomerModel;
/**
* Customer service
* @property Image|\fecshop\services\Product\Image $image ,This property is read-only.
......@@ -126,6 +127,38 @@ class Customer extends Service
return Yii::$app->user->identity->username;
}
/**
* get CustomerModel by Email address
*/
protected function actionGetUserIdentityByEmail($email){
$one = CustomerModel::findByEmail($email);
if($one['email']){
return $one;
}else{
return false;
}
}
/**
* @property $identify|object(customer object) or String
* @return 生成的resetToken,如果生成失败返回false
* 用来找回密码,生成resetToken,返回
*/
protected function actionGeneratePasswordResetToken($identify){
if(is_string($identify)){
$email = $identify;
$one = $this->getUserIdentityByEmail($email);
}else{
$one = $identify;
}
if($one){
$one->generatePasswordResetToken();
$one->save();
return $one->password_reset_token;
}
return false;
}
}
\ No newline at end of file
......@@ -120,9 +120,18 @@ class Email extends Service
}
/**
*
* [
'to' => $to,
'subject' => $subject,
'htmlBody' => $htmlBody,
'senderName'=> $senderName,
]
*/
protected function actionSend($to,$subject,$htmlBody,$mailerConfigParam=''){
protected function actionSend($sendInfo,$mailerConfigParam=''){
$to = isset($sendInfo['to']) ? $sendInfo['to'] : '';
$subject = isset($sendInfo['subject']) ? $sendInfo['subject'] : '';
$htmlBody = isset($sendInfo['htmlBody']) ? $sendInfo['htmlBody'] : '';
$senderName = isset($sendInfo['senderName']) ? $sendInfo['senderName'] : '';
/*
$this->mailer()->compose()
->setFrom('support@onfancymail.com')
......@@ -154,15 +163,21 @@ class Email extends Service
}else{
$from = $this->_from;
}
/*
echo $from;
echo '<br/><br/>';
echo $to;echo '<br/><br/>';
echo $subject;echo '<br/><br/>';
echo $htmlBody;echo '<br/><br/>';
var_dump($mailer);
*/
if($senderName){
$setFrom = [$from => $senderName];
}else{
$setFrom = $from;
}
$mailer->compose()
->setFrom($from)
->setFrom($setFrom)
->setTo($to)
->setSubject($subject)
->setHtmlBody($htmlBody)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册