/** * @inheritdoc */ public function beforeAction($action) { if (Yii::$app->request->get('token') === null) { throw new ForbiddenHttpException(Module::t('errors', 'Invalid authentication token.')); } return true; }
/** * Validates that the account exists. * * @param string $attribute attribute name. * @param array $params additional parameters. */ public function validateAccountExists($attribute, $params) { $account = Module::getInstance()->getDataContract()->findAccount(['email' => $this->email]); if ($account === null) { $this->addError($attribute, Module::t('errors', 'Please check the e-mail address.')); } }
/** * Validates that the account is not locked. * * @param string $attribute validated attribute. * @param array $params additional parameters. */ public function validateAccountNotLocked($attribute, $params) { $account = $this->getAccount(); if ($account !== null && Module::getInstance()->getDataContract()->isAccountLocked($account)) { $this->addError($attribute, Module::t('errors', 'Your account has been locked due to too many failed login attempts.')); } }
/** * Validates that the account exists. * * @param string $attribute attribute name. * @param array $params additional parameters. */ public function validateAccountExists($attribute, $params) { $account = Module::getInstance()->getDataContract()->findAccount(['email' => $this->email]); if ($account === null) { $this->addError($attribute, Module::t('errors', 'There is no account is associated with this e-mail address.')); } }
<?php echo Html::submitButton(Module::t('views', 'Login'), ['class' => 'btn btn-lg btn-primary']); ?> <?php ActiveForm::end(); ?> <?php if (Module::getInstance()->enableClientAuth) { ?> <hr/> <p class="help-block"> <?php echo Module::t('views', 'You may also log in using one of the providers below:'); ?> </p> <?php echo AuthChoice::widget(); ?> <?php } ?> </div> </div> </div>
<?php echo Module::t('views', 'Please enter a new password twice to change the your password.'); ?> </p> <?php $form = ActiveForm::begin(['id' => 'passwordform']); ?> <fieldset> <?php echo $form->field($model, 'password')->passwordInput(); ?> <?php echo $form->field($model, 'verifyPassword')->passwordInput(); ?> </fieldset> <?php echo Html::submitButton(Module::t('views', 'Change Password'), ['class' => 'btn btn-lg btn-primary']); ?> <?php ActiveForm::end(); ?> </div> </div> </div>
</h1> <p class="help-block"> <?php echo Module::t('views', 'Please enter your e-mail address and we will send you instructions on how to reset your password.'); ?> </p> <?php $form = ActiveForm::begin(['id' => 'forgotpasswordform']); ?> <fieldset> <?php echo $form->field($model, 'email'); ?> </fieldset> <?php echo Html::submitButton(Module::t('views', 'Send'), ['class' => 'btn btn-lg btn-primary']); ?> <?php ActiveForm::end(); ?> </div> </div> </div>
/** * @inheritdoc */ public function attributeLabels() { return ArrayHelper::merge(parent::attributeLabels(), ['email' => Module::t('labels', 'Email'), 'username' => Module::t('labels', 'Username'), 'captcha' => Module::t('labels', 'Verification Code')]); }
/* * This file is part of Account. * * (c) 2014 Nord Software * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use nord\yii\account\Module; use yii\helpers\Html; /* @var $this yii\web\View */ $this->title = Module::t('views', 'Success'); ?> <div class="password-controller sent-action"> <h1 class="page-header"><?php echo Html::encode($this->title); ?> </h1> <p class="lead"><?php echo Module::t('views', 'Do not worry'); ?> </p> <p><?php echo Module::t('views', 'You will soon receive an email with instructions on how to reset the password for your account.'); ?> </p> </div>
* This file is part of Account. * * (c) 2014 Nord Software * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use nord\yii\account\Module; use yii\helpers\Html; /* @var $this yii\web\View */ $this->title = Module::t('views', 'Sign up successful'); ?> <div class="register-controller done-action"> <h1 class="page-header"><?php echo Html::encode($this->title); ?> </h1> <p class="lead"><?php echo Module::t('views', 'You will soon receive an email with instructions on how to activate your account.'); ?> </p> <p><?php echo Html::a(Module::t('views', 'Done'), Yii::$app->homeUrl, ['class' => 'btn btn-primary btn-lg']); ?> </p> </div>
/** * @inheritdoc */ public function attributeLabels() { return ['id' => Module::t('labels', 'ID'), 'accountId' => Module::t('labels', 'Account ID'), 'type' => Module::t('labels', 'Type'), 'token' => Module::t('labels', 'Token'), 'createdAt' => Module::t('labels', 'Created At'), 'status' => Module::t('labels', 'Status')]; }
<?php /* * This file is part of Account. * * (c) 2014 Nord Software * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use nord\yii\account\Module; use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $actionUrl string */ echo Module::t('email', 'Thank you for signing up'); ?> <br><br> <?php echo Module::t('email', 'Please click the link below to activate your account:'); ?> <br> <?php echo Html::a($actionUrl, $actionUrl);
* This file is part of Account. * * (c) 2014 Nord Software * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use nord\yii\account\Module; use yii\helpers\Html; /* @var $this yii\web\View */ $this->title = Module::t('views', 'Success'); ?> <div class="register-controller done-action"> <h1 class="page-header"><?php echo Html::encode($this->title); ?> </h1> <p class="lead"><?php echo Module::t('views', 'Thank you for signing up!'); ?> </p> <p><?php echo Module::t('views', 'You will soon receive an email with instructions on how to activate your account.'); ?> </p> </div>
<?php /* * This file is part of Account. * * (c) 2014 Nord Software * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ use nord\yii\account\Module; use yii\helpers\Html; /* @var $this yii\web\View */ /* @var $actionUrl string */ echo Module::t('email', 'You have requested to reset your password'); ?> <br><br> <?php echo Module::t('email', 'Please click the link below to reset the password for your account:'); ?> <br> <?php echo Html::a($actionUrl, $actionUrl);
/** * Sends a test "recover pasword" e-mail to the specified e-mail address * * @param string $email */ public function actionTestResendPasswordEmail($email) { $actionUrl = 'http://example.com/recoverPassword/' . $email; $this->module->getMailSender()->sendResetPasswordMail(['to' => [$email], 'from' => $this->module->getParam(Module::PARAM_FROM_EMAIL_ADDRESS), 'subject' => Module::t('email', 'Thank you for signing up'), 'data' => ['actionUrl' => $actionUrl]]); }
/** * Validates that the password has not been used in the past. * * @param string $attribute attribute name. * @param array $params additional parameters. */ public function validatePasswordHistory($attribute, $params) { if (Module::getInstance()->getDataContract()->isAccountPasswordUsed($this->account, $this->{$attribute})) { $this->addError($attribute, Module::t('errors', 'You have already used this password.')); } }
/** * @inheritdoc */ public function attributeLabels() { return ['id' => Module::t('labels', 'ID'), 'accountId' => Module::t('labels', 'Account ID'), 'name' => Module::t('labels', 'Name'), 'clientId' => Module::t('labels', 'Client ID'), 'data' => Module::t('labels', 'Data')]; }
</h1> <p class="help-block"> <?php echo Module::t('views', 'Please enter your e-mail address and we will send you instructions on how to reset your password.'); ?> </p> <?php $form = ActiveForm::begin(['id' => 'forgotpasswordform']); ?> <fieldset> <?php echo $form->field($model, 'email'); ?> </fieldset> <?php echo Html::submitButton(Module::t('views', 'Recover Account'), ['class' => 'btn btn-lg btn-primary']); ?> <?php ActiveForm::end(); ?> </div> </div> </div>
/** * Sends a reset password email to owner of the given account. * * @param ActiveRecord $account model instance. */ protected function sendResetPasswordMail(ActiveRecord $account) { $token = $this->module->generateToken(Module::TOKEN_RESET_PASSWORD, $account->id); $actionUrl = $this->module->createUrl([Module::URL_ROUTE_RESET_PASSWORD, 'token' => $token], true); $this->module->getMailSender()->sendResetPasswordMail(['to' => [$account->email], 'from' => $this->module->getParam(Module::PARAM_FROM_EMAIL_ADDRESS), 'subject' => Module::t('email', 'Reset password'), 'data' => ['actionUrl' => $actionUrl]]); }
/** * @inheritdoc */ public function attributeLabels() { return ['id' => Module::t('labels', 'ID'), 'accountId' => Module::t('labels', 'Account ID'), 'success' => Module::t('labels', 'Success'), 'numFailedAttempts' => Module::t('labels', '# Failed Attempts'), 'createdAt' => Module::t('labels', 'Created At')]; }
/** * @inheritdoc */ public function attributeLabels() { return ['email' => Module::t('labels', 'Email'), 'username' => Module::t('labels', 'Username')]; }
/** * @inheritdoc */ public function attributeLabels() { return ['id' => Module::t('labels', 'ID'), 'username' => Module::t('labels', 'Username'), 'password' => Module::t('labels', 'Password'), 'authKey' => Module::t('labels', 'Authentication Key'), 'email' => Module::t('labels', 'Email'), 'lastLoginAt' => Module::t('labels', 'Last Login At'), 'createdAt' => Module::t('labels', 'Created At'), 'status' => Module::t('labels', 'Status')]; }
/** * @param string $message error message. * @throws HttpException when called. */ public function fatalError($message = null) { throw new ServerErrorHttpException($message === null ? Module::t('errors', 'Something went wrong.') : $message); }
/** * Sends an activation email to owner of the given account. * * @param ActiveRecord $account account instance. */ protected function sendActivationMail(ActiveRecord $account) { $token = $this->module->generateToken(Module::TOKEN_ACTIVATE, $account->id); $actionUrl = $this->module->createUrl([Module::URL_ROUTE_ACTIVATE, 'token' => $token], true); $this->module->getMailSender()->sendActivationMail(['to' => [$account->email], 'from' => $this->module->getParam(Module::PARAM_FROM_EMAIL_ADDRESS), 'subject' => Module::t('email', 'Thank you for signing up'), 'data' => ['actionUrl' => $actionUrl]]); }
/** * @inheritdoc */ public function attributeLabels() { return ['id' => Module::t('labels', 'ID'), 'accountId' => Module::t('labels', 'Account ID'), 'password' => Module::t('labels', 'Password'), 'createdAt' => Module::t('labels', 'Created At')]; }
/** * @inheritdoc */ public function validateAttribute($object, $attribute) { $password = $object->{$attribute}; $length = mb_strlen($password); if ($this->minLength && $length < $this->minLength) { $this->addError($object, $attribute, Module::t('errors', "{attribute} is too short, minimum is {n} {n, plural, =1{character} other{characters}}.", ['n' => $this->minLength])); return false; } if ($this->minDigits) { $digits = ''; if (preg_match_all("/[\\d+]/u", $password, $matches)) { $digits = implode('', $matches[0]); } if (mb_strlen($digits) < $this->minDigits) { $this->addError($object, $attribute, Module::t('errors', "{attribute} should contain at least {n} {n, plural, =1{digit} other{digits}}.", ['n' => $this->minLength])); return false; } } if ($this->minUpperCaseLetters) { $numUpperCaseChars = ''; if (preg_match_all("/[A-Z]/u", $password, $matches)) { $numUpperCaseChars = implode('', $matches[0]); } if (mb_strlen($numUpperCaseChars) < $this->minUpperCaseLetters) { $this->addError($object, $attribute, Module::t('errors', "{attribute} should contain at least {n} upper case {n, plural, =1{character} other{characters}}.", ['n' => $this->minLength])); return false; } } if ($this->minLowerCaseLetters) { $numLowerCaseChars = ''; if (preg_match_all("/[a-z]/u", $password, $matches)) { $numLowerCaseChars = implode('', $matches[0]); } if (mb_strlen($numLowerCaseChars) < $this->minLowerCaseLetters) { $this->addError($object, $attribute, Module::t('errors', "{attribute} should contain at least {n} lower case {n, plural, =1{character} other{characters}}.", ['n' => $this->minLength])); return false; } } if ($this->minSpecialChars) { $numSpecialChars = ''; if (preg_match_all("/[" . implode('|', $this->specialChars) . "]/u", $password, $matches)) { $numSpecialChars = implode('', $matches[0]); } if (mb_strlen($numSpecialChars) < $this->minSpecialChars) { $this->addError($object, $attribute, Module::t('errors', "{attribute} should contain at least {n} non alpha numeric {n, plural, =1{character} other{characters}}.", ['n' => $this->minLength])); return false; } } return true; }