Moves newsletter hash generating logic into Security helper class

Updates Links class to use Security helper's hash generating method
This commit is contained in:
Vlad
2017-05-14 17:54:53 -04:00
parent a3e8d47199
commit 6e700b0cfa
6 changed files with 32 additions and 17 deletions

View File

@@ -19,7 +19,6 @@ class Newsletter extends Model {
const STATUS_SENT = 'sent';
// automatic newsletters status
const STATUS_ACTIVE = 'active';
const NEWSLETTER_HASH_LENGTH = 6;
function __construct() {
parent::__construct();
@@ -80,7 +79,7 @@ class Newsletter extends Model {
$this->set('hash',
($this->hash)
? $this->hash
: self::generateHash()
: Security::generateHash()
);
return parent::save();
}
@@ -787,12 +786,4 @@ class Newsletter extends Model {
return parent::where('hash', $hash)
->findOne();
}
static function generateHash() {
return substr(
md5(AUTH_KEY . Security::generateRandomString(15)),
0,
self::NEWSLETTER_HASH_LENGTH
);
}
}