提交 21fd8e33 编写于 作者: T Terry

apphtml customer account login and register

上级 cee682f2
......@@ -20,8 +20,11 @@ class Login
{
public function getLastData($param = '')
{
$loginParam = \Yii::$app->getModule('customer')->params['login'];
$loginPageCaptcha = isset($loginParam['loginPageCaptcha']) ? $loginParam['loginPageCaptcha'] : false;
//$loginParam = \Yii::$app->getModule('customer')->params['login'];
$appName = Yii::$service->helper->getAppName();
$loginPageCaptcha = Yii::$app->store->get($appName.'_account', 'loginPageCaptcha');
$loginPageCaptcha = ($loginPageCaptcha == Yii::$app->store->enable) ? true : false;
$email = isset($param['email']) ? $param['email'] : '';
return [
......@@ -35,8 +38,11 @@ class Login
public function login($param)
{
$captcha = $param['captcha'];
$loginParam = \Yii::$app->getModule('customer')->params['login'];
$loginPageCaptcha = isset($loginParam['loginPageCaptcha']) ? $loginParam['loginPageCaptcha'] : false;
//$loginParam = \Yii::$app->getModule('customer')->params['login'];
//$loginPageCaptcha = isset($loginParam['loginPageCaptcha']) ? $loginParam['loginPageCaptcha'] : false;
$appName = Yii::$service->helper->getAppName();
$loginPageCaptcha = Yii::$app->store->get($appName.'_account', 'loginPageCaptcha');
$loginPageCaptcha = ($loginPageCaptcha == Yii::$app->store->enable) ? true : false;
if ($loginPageCaptcha && !$captcha) {
Yii::$service->page->message->addError(['Captcha can not empty']);
......
......@@ -23,9 +23,10 @@ class Register
$firstname = isset($param['firstname']) ? $param['firstname'] : '';
$lastname = isset($param['lastname']) ? $param['lastname'] : '';
$email = isset($param['email']) ? $param['email'] : '';
$registerParam = \Yii::$app->getModule('customer')->params['register'];
$registerPageCaptcha = isset($registerParam['registerPageCaptcha']) ? $registerParam['registerPageCaptcha'] : false;
//$registerParam = \Yii::$app->getModule('customer')->params['register'];
//$registerPageCaptcha = isset($registerParam['registerPageCaptcha']) ? $registerParam['registerPageCaptcha'] : false;
$appName = Yii::$service->helper->getAppName();
$registerPageCaptcha = Yii::$app->store->get($appName.'_account', 'registerPageCaptcha');
return [
'firstname' => $firstname,
'lastname' => $lastname,
......@@ -35,17 +36,19 @@ class Register
'maxNameLength' => Yii::$service->customer->getRegisterNameMaxLength(),
'minPassLength' => Yii::$service->customer->getRegisterPassMinLength(),
'maxPassLength' => Yii::$service->customer->getRegisterPassMaxLength(),
'registerPageCaptcha' => $registerPageCaptcha,
'registerPageCaptcha' => ($registerPageCaptcha == Yii::$app->store->enable ? true : false),
];
}
public function register($param)
{
$captcha = $param['captcha'];
$registerParam = \Yii::$app->getModule('customer')->params['register'];
$registerPageCaptcha = isset($registerParam['registerPageCaptcha']) ? $registerParam['registerPageCaptcha'] : false;
// 如果开启了验证码,但是验证码验证不正确就报错返回。
if ($registerPageCaptcha && !$captcha) {
$appName = Yii::$service->helper->getAppName();
$registerPageCaptcha = Yii::$app->store->get($appName.'_account', 'registerPageCaptcha');
//$registerParam = \Yii::$app->getModule('customer')->params['register'];
//$registerPageCaptcha = isset($registerParam['registerPageCaptcha']) ? $registerParam['registerPageCaptcha'] : false;// 如果开启了验证码,但是验证码验证不正确就报错返回。
if (($registerPageCaptcha == Yii::$app->store->enable) && !$captcha) {
Yii::$service->page->message->addError(['Captcha can not empty']);
return;
......
......@@ -80,21 +80,25 @@ class AccountController extends AppfrontController
$registerStatus = $this->getBlock()->register($param);
//echo $registerStatus;exit;
if ($registerStatus) {
$params_register = Yii::$app->getModule('customer')->params['register'];
// $params_register = Yii::$app->getModule('customer')->params['register'];
$appName = Yii::$service->helper->getAppName();
$registerSuccessAutoLogin = Yii::$app->store->get($appName.'_account', 'registerSuccessAutoLogin');
$registerSuccessRedirectUrlKey = Yii::$app->store->get($appName.'_account', 'registerSuccessRedirectUrlKey');
// 是否需要邮件激活?
if (Yii::$service->email->customer->registerAccountIsNeedEnableByEmail) {
$correctMessage = Yii::$service->page->translate->__("Your account registration is successful, we sent an email to your email, you need to login to your email and click the activation link to activate your account. If you have not received the email, you can resend the email by {url_click_here_before}clicking here{url_click_here_end} {end_text}", ['url_click_here_before' => '<span class="email_register_resend" >', 'url_click_here_end' => '</span>', 'end_text'=> '<span class="resend_text"></span>' ]);
Yii::$service->page->message->AddCorrect($correctMessage);
} else { // 如果不需要邮件激活?
// 注册成功后,是否自动登录
if (isset($params_register['successAutoLogin']) && $params_register['successAutoLogin']) {
if ($registerSuccessAutoLogin == Yii::$app->store->enable) {
Yii::$service->customer->login($param);
}
if (!Yii::$app->user->isGuest) {
// 注册成功后,跳转的页面,如果值为false, 则不跳转。
$urlKey = 'customer/account';
if (isset($params_register['loginSuccessRedirectUrlKey']) && $params_register['loginSuccessRedirectUrlKey']) {
$urlKey = $params_register['loginSuccessRedirectUrlKey'];
if ($registerSuccessRedirectUrlKey) {
$urlKey = $registerSuccessRedirectUrlKey;
}
return Yii::$service->customer->loginSuccessRedirect($urlKey);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册