/** * @inheritDoc */ public function init() { parent::init(); if ($this->emailSubject === null) { $this->emailSubject = Helper::t('email', 'Thank you for signing up'); } }
/** * Authenticates the password. * This is the 'authenticate' validator as declared in rules(). */ public function authenticate($attribute, $params) { if (!$this->hasErrors()) { $identityClass = Helper::getModule()->getClassName(Module::CLASS_USER_IDENTITY); $this->_identity = new $identityClass($this->username, $this->password); $success = $this->_identity->authenticate(); $account = $this->_identity->getAccount(); if ($account !== null && $this->isAccountLocked($account->id)) { $this->addError('password', Helper::t('errors', 'Your account has been temporarily locked due to too many failed login attempts.')); } if (!$success) { $this->createHistoryEntry($account !== null ? $account->id : 0, false); $this->addError('password', Helper::t('errors', 'Your username or password is invalid.')); } } }
<?php use nordsoftware\yii_account\helpers\Helper; /* @var $this \nordsoftware\yii_account\controllers\SignupController */ ?> <div class="register-controller done-action"> <h1><?php echo CHtml::encode(Yii::app()->name); ?> </h1> <p class="lead"><?php echo Helper::t('views', 'Thank you for registering!'); ?> </p> <p><?php echo Helper::t('views', 'You will soon receive an email with instructions on how to activate your account.'); ?> </p> </div>
<?php use nordsoftware\yii_account\helpers\Helper; /* @var $this \nordsoftware\yii_account\controllers\PasswordController */ /* @var $resetUrl string */ echo Helper::t('email', 'Reset password'); ?> <br> <br> <?php echo Helper::t('email', 'Please click the link below to reset the password for your account:'); ?> <br> <?php echo CHtml::link($resetUrl, $resetUrl);
?> </p> <?php $form = $this->beginWidget('\\TbActiveForm', array('id' => $this->forgotFormId, 'enableAjaxValidation' => true)); ?> <fieldset> <?php echo $form->textFieldControlGroup($model, 'email', array('label' => false, 'placeholder' => $model->getAttributeLabel('email'), 'block' => true)); ?> </fieldset> <div class="row"> <div class="forgot-submit col-xs-8"> <?php echo TbHtml::submitButton(Helper::t('views', 'Recover Account'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'block' => true)); ?> </div> <div class="forgot-cancel col-xs-4"> <?php echo TbHtml::linkButton(Helper::t('views', 'Cancel'), array('url' => array('/account/authenticate/login'), 'color' => TbHtml::BUTTON_COLOR_LINK, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'block' => true)); ?> </div> </div> <?php $this->endWidget(); ?> </div>
/** * @inheritDoc */ public function attributeLabels() { return array_merge(parent::attributeLabels(), array('email' => Helper::t('labels', 'Email'), 'username' => Helper::t('labels', 'Username'))); }
/** * Performs logic to change the password for an account. * * @param \nordsoftware\yii_account\models\ar\AccountToken $tokenModel authentication token model. * @return \nordsoftware\yii_account\models\form\PasswordForm the form model. */ protected function changePasswordInternal(AccountToken $tokenModel) { $modelClass = $this->module->getClassName(Module::CLASS_PASSWORD_FORM); /** @var \nordsoftware\yii_account\models\form\PasswordForm $model */ $model = new $modelClass(); $request = \Yii::app()->request; $this->runAjaxValidation($model, $this->changeFormId); if ($request->isPostRequest) { $model->attributes = $request->getPost(Helper::classNameToPostKey($modelClass)); if ($model->validate()) { $accountClass = $this->module->getClassName(Module::CLASS_ACCOUNT); /** @var \nordsoftware\yii_account\models\ar\Account $account */ $account = \CActiveRecord::model($accountClass)->findByPk($tokenModel->accountId); // Check that the password has not been used in the past. if ($model->checkPasswordHistory($account, $model->password)) { $model->addError('password', Helper::t('errors', 'You have already used this password.')); } if (!$model->hasErrors() && $account->changePassword($model->password, true)) { $model->createHistoryEntry($account->id, $account->salt, $account->password); // We need to reset the requireNewPassword flag if applicable when the password has been changed. if ($account->requireNewPassword && !$account->saveAttributes(array('requireNewPassword' => false))) { $this->fatalError(); } if (!$tokenModel->saveAttributes(array('status' => AccountToken::STATUS_USED))) { $this->fatalError(); } $this->redirect(array('/account/authenticate/login')); } // todo: figure out how to avoid this, the problem is that password validation is done on the account $model->addError('password', $account->getError('password')); } } return $model; }
<?php echo Helper::t('views', 'Please enter a new password twice to change the password for your account.'); ?> </p> <?php $form = $this->beginWidget('\\TbActiveForm', array('id' => $this->changeFormId, 'enableAjaxValidation' => true)); ?> <fieldset> <?php echo $form->passwordFieldControlGroup($model, 'password', array('label' => false, 'placeholder' => $model->getAttributeLabel('password'), 'block' => true)); ?> <?php echo $form->passwordFieldControlGroup($model, 'verifyPassword', array('label' => false, 'placeholder' => $model->getAttributeLabel('verifyPassword'), 'block' => true)); ?> </fieldset> <div class="row"> <div class="forgot-submit col-xs-8"> <?php echo TbHtml::submitButton(Helper::t('views', 'Change Password'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'block' => true)); ?> </div> </div> <?php $this->endWidget(); ?> </div>
?> <?php echo $form->passwordFieldControlGroup($model, 'password', array('label' => false, 'placeholder' => $model->getAttributeLabel('password'), 'block' => true)); ?> <?php echo $form->passwordFieldControlGroup($model, 'verifyPassword', array('label' => false, 'placeholder' => $model->getAttributeLabel('verifyPassword'), 'block' => true)); ?> <?php if ($model->scenario === 'withCaptcha') { ?> <?php echo $form->textFieldControlGroup($model, 'captcha', array('label' => false, 'placeholder' => $model->getAttributeLabel('captcha'), 'block' => true, 'controlOptions' => array('before' => $this->widget($this->module->getClassName(Module::CLASS_CAPTCHA_WIDGET), array(), true)))); ?> <?php } ?> </fieldset> <div class="row"> <div class="register-submit col-xs-8"> <?php echo TbHtml::submitButton(Helper::t('views', 'Create Account'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'block' => true)); ?> </div> </div> <?php $this->endWidget(); ?> </div>
public function validateAccountExists($attribute, $params) { if (($model = $this->loadModel($this->email)) === null) { $this->addError($attribute, Helper::t('errors', 'Account not found.')); } }
<?php use nordsoftware\yii_account\helpers\Helper; /* @var $this \nordsoftware\yii_account\controllers\SignupController */ /* @var $activateUrl string */ echo Helper::t('email', 'Thank you for signing up'); ?> <br> <br> <?php echo Helper::t('email', 'Please click the link below to activate your account:'); ?> <br> <?php echo CHtml::link($activateUrl, $activateUrl);
/** * @inheritDoc */ public function attributeLabels() { return array('id' => Helper::t('labels', 'ID'), 'accountId' => Helper::t('labels', 'Account'), 'type' => Helper::t('labels', 'Type'), 'token' => Helper::t('labels', 'Token'), 'createdAt' => Helper::t('labels', 'Created At'), 'status' => Helper::t('labels', 'Status')); }
/** * @inheritDoc */ public function attributeLabels() { return array('password' => Helper::t('labels', 'Password'), 'verifyPassword' => Helper::t('labels', 'Verify Password')); }
/** * @param string $message error message. * @throws \CHttpException when called. */ public function fatalError($message = null) { throw new \CHttpException(500, $message === null ? Helper::t('errors', 'Something went wrong.') : $message); }
/** * @inheritDoc */ public function attributeLabels() { return array('id' => Helper::t('labels', 'ID'), 'salt' => Helper::t('labels', 'Salt'), 'username' => Helper::t('labels', 'Username'), 'password' => Helper::t('labels', 'Password'), 'email' => Helper::t('labels', 'Email'), 'passwordStrategy' => Helper::t('labels', 'Password Strategy'), 'requireNewPassword' => Helper::t('labels', 'Require New Password'), 'lastLoginAt' => Helper::t('labels', 'Last Login At'), 'lastActiveAt' => Helper::t('labels', 'Last Active At'), 'status' => Helper::t('labels', 'Status')); }
<div class="row"> <div class="login-submit col-xs-6"> <?php echo TbHtml::submitButton(Helper::t('views', 'Log In'), array('color' => TbHtml::BUTTON_COLOR_PRIMARY, 'size' => TbHtml::BUTTON_SIZE_LARGE, 'block' => true)); ?> </div> <div class="login-stay-logged-in col-xs-6"> <?php echo $form->checkBoxControlGroup($model, 'stayLoggedIn'); ?> </div> </div> <?php $this->endWidget(); ?> <ul class="login-links list-unstyled"> <li><?php echo TbHtml::link(Helper::t('views', 'Create an account'), array('/account/signup/index')); ?> </li> <li>|</li> <li><?php echo TbHtml::link(Helper::t('views', 'Forgot password'), array('/account/password/forgot')); ?> </li> </ul> </div>