/**
  * Check if secure key is valid.
  *
  * @return boolean true if secure key is valid
  */
 public function isValidSecureKey()
 {
     if (Security::isValidToken($this->secure_key, $this->module->recoveryWithin) === true) {
         return ($this->_user = User::findBySecureKey($this->secure_key, 'active')) !== null;
     }
     return false;
 }
 /**
  * @return string SQL to insert first user
  */
 private function getUserSql()
 {
     $time = time();
     $password_hash = Yii::$app->security->generatePasswordHash('admin12345');
     $auth_key = Yii::$app->security->generateRandomString();
     $secure_key = Security::generateExpiringRandomKey();
     return "INSERT INTO {{%users}} (`username`, `email`, `password_hash`, `auth_key`, `secure_key`, `role`, `status_id`, `created_at`, `updated_at`) VALUES ('admin', '*****@*****.**', '{$password_hash}', '{$auth_key}', '{$secure_key}', 'superadmin', 1, {$time}, {$time})";
 }
Example #3
0
 /**
  * Generates secure key.
  */
 public function generateToken()
 {
     $this->token = Security::generateExpiringRandomKey();
 }
Example #4
0
 /**
  * Generates secure key.
  */
 public function generateSecureKey()
 {
     $this->secure_key = Security::generateExpiringRandomKey();
 }