Exemplo n.º 1
0
 /**
  * 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.'));
     }
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function beforeAction($action)
 {
     if (!Module::getInstance()->enableSignup) {
         $this->owner->pageNotFound();
     }
     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.'));
     }
 }
Exemplo n.º 4
0
 /**
  * Validates this model and creates a new account for the user.
  *
  * @return boolean whether sign-up was successful.
  */
 public function signup()
 {
     if ($this->validate()) {
         $dataContract = Module::getInstance()->getDataContract();
         $account = $dataContract->createAccount(['attributes' => $this->attributes]);
         if ($account->validate()) {
             if ($account->save(false)) {
                 $dataContract->createPasswordHistory(['accountId' => $account->id, 'password' => $account->password]);
                 return true;
             }
         }
         foreach ($account->getErrors('password') as $error) {
             $this->addError('password', $error);
         }
     }
     return false;
 }
Exemplo n.º 5
0
 /**
  * Generates a new truly unique random token and saves it in the database.
  *
  * @param string $type token type.
  * @param integer $accountId account id.
  * @return string the generated token.
  */
 public function generateToken($type, $accountId)
 {
     $dataContract = $this->getDataContract();
     $attributes = ['accountId' => $accountId, 'type' => $type];
     while (!isset($attributes['token'])) {
         $attributes['token'] = Module::getInstance()->getTokenGenerator()->generate();
         if ($dataContract->findToken($attributes) !== null) {
             unset($attributes['token']);
         }
     }
     $dataContract->createToken(['attributes' => $attributes]);
     return $attributes['token'];
 }
Exemplo n.º 6
0
 /**
  * Returns the account associated with the value of the login attribute.
  *
  * @return Account model instance.
  */
 public function getAccount()
 {
     if ($this->_account === null) {
         $this->_account = Module::getInstance()->getDataContract()->findAccount([Module::getInstance()->loginAttribute => $this->username]);
     }
     return $this->_account;
 }
Exemplo n.º 7
0
?>
                <?php 
echo $form->field($model, 'rememberMe')->checkbox();
?>
            </fieldset>

            <?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 
}
?>
Exemplo n.º 8
0
            <fieldset>
                <?php 
echo $form->field($model, 'email');
?>
                <?php 
echo $form->field($model, 'username');
?>
                <?php 
echo $form->field($model, 'password')->passwordInput();
?>
                <?php 
echo $form->field($model, 'verifyPassword')->passwordInput();
?>
                <?php 
if (Module::getInstance()->enableCaptcha) {
    ?>
                    <?php 
    echo $form->field($model, 'captcha')->widget($captchaClass, ['captchaAction' => Module::URL_ROUTE_CAPTCHA, 'template' => '<div class="row"><div class="col-lg-3">{image}</div><div class="col-lg-9">{input}</div></div>', 'imageOptions' => ['height' => 35]]);
    ?>

                    <p class="help-block">
                        <?php 
    echo Module::t('views', 'Please enter the verification code in the field above.');
    ?>
                    </p>
                <?php 
}
?>
            </fieldset>
Exemplo n.º 9
0
 /**
  * Creates a password history entry.
  *
  * @param Account $account model instance.
  */
 public function createHistoryEntry(ActiveRecord $account)
 {
     Module::getInstance()->getDataContract()->createPasswordHistory(['accountId' => $account->getPrimaryKey(), 'password' => $account->password]);
 }
Exemplo n.º 10
0
 /**
  * Generates "remember me" authentication key
  */
 public function generateAuthKey()
 {
     $this->authKey = Module::getInstance()->getTokenGenerator()->generate();
 }
Exemplo n.º 11
0
 /**
  * Returns a model class using the given condition.
  *
  * @param string $className class name.
  * @param mixed $condition search condition.
  * @return ActiveRecord|null model instance or null if not found.
  */
 protected function findInternal($className, $condition)
 {
     /** @var ActiveRecord $modelClass */
     $modelClass = Module::getInstance()->getClassName($className);
     return $modelClass::findOne($condition);
 }
 /**
  * @return PasswordHasherInterface
  */
 protected function getPasswordHasher()
 {
     return Module::getInstance()->getPasswordHasher();
 }