- Добавлен метод генерирующий новую запись с хешем в базе

parent 0961ed94
...@@ -50,4 +50,22 @@ class AuthHashes extends \yii\db\ActiveRecord ...@@ -50,4 +50,22 @@ class AuthHashes extends \yii\db\ActiveRecord
'valid_date' => 'Valid Date', 'valid_date' => 'Valid Date',
]; ];
} }
/**
* @param $email
* @return string
*/
public static function setNewHash($email)
{
$validDate = new \DateTime();
$validDate->modify('+3 hours');
$hash = Yii::$app->security->generateRandomString(50);
$model = new AuthHashes();
$model->email = $email;
$model->hash = $hash;
$model->auth_count = 0;
$model->valid_date = $validDate->format('Y-m-d H:i:s');
if ($model->save())
return $hash;
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment