CC-4090: Make code style PSR compliant
-User.php -removed all trailing whitespace
This commit is contained in:
parent
3d243468a7
commit
ee3447f903
30 changed files with 1057 additions and 1037 deletions
|
@ -1,53 +1,53 @@
|
|||
<?php
|
||||
|
||||
class Application_Model_Auth {
|
||||
|
||||
const TOKEN_LIFETIME = 'P2D'; // DateInterval syntax
|
||||
|
||||
private function generateToken($action, $user_id)
|
||||
{
|
||||
$salt = md5("pro");
|
||||
$token = self::generateRandomString();
|
||||
|
||||
$info = new CcSubjsToken();
|
||||
$info->setDbUserId($user_id);
|
||||
$info->setDbAction($action);
|
||||
$info->setDbToken(sha1($token.$salt));
|
||||
$info->setDbCreated(gmdate('Y-m-d H:i:s'));
|
||||
$info->save();
|
||||
|
||||
Logging::debug("generated token {$token}");
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function sendPasswordRestoreLink($user, $view)
|
||||
{
|
||||
|
||||
const TOKEN_LIFETIME = 'P2D'; // DateInterval syntax
|
||||
|
||||
private function generateToken($action, $user_id)
|
||||
{
|
||||
$salt = md5("pro");
|
||||
$token = self::generateRandomString();
|
||||
|
||||
$info = new CcSubjsToken();
|
||||
$info->setDbUserId($user_id);
|
||||
$info->setDbAction($action);
|
||||
$info->setDbToken(sha1($token.$salt));
|
||||
$info->setDbCreated(gmdate('Y-m-d H:i:s'));
|
||||
$info->save();
|
||||
|
||||
Logging::debug("generated token {$token}");
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
public function sendPasswordRestoreLink($user, $view)
|
||||
{
|
||||
$token = $this->generateToken('password.restore', $user->getDbId());
|
||||
|
||||
|
||||
$e_link_protocol = empty($_SERVER['HTTPS']) ? "http" : "https";
|
||||
$e_link_base = $_SERVER['SERVER_NAME'];
|
||||
$e_link_path = $view->url(array('user_id' => $user->getDbId(), 'token' => $token), 'password-change');
|
||||
|
||||
|
||||
$message = "Click this link: {$e_link_protocol}://{$e_link_base}{$e_link_path}";
|
||||
|
||||
$success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail());
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function invalidateTokens($user, $action)
|
||||
{
|
||||
CcSubjsTokenQuery::create()
|
||||
->filterByDbAction($action)
|
||||
->filterByDbUserId($user->getDbId())
|
||||
->delete();
|
||||
}
|
||||
|
||||
|
||||
$success = Application_Model_Email::send('Airtime Password Reset', $message, $user->getDbEmail());
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function invalidateTokens($user, $action)
|
||||
{
|
||||
CcSubjsTokenQuery::create()
|
||||
->filterByDbAction($action)
|
||||
->filterByDbUserId($user->getDbId())
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function checkToken($user_id, $token, $action)
|
||||
{
|
||||
$salt = md5("pro");
|
||||
|
||||
$salt = md5("pro");
|
||||
|
||||
$token_info = CcSubjsTokenQuery::create()
|
||||
->filterByDbAction($action)
|
||||
->filterByDbUserId($user_id)
|
||||
|
@ -61,10 +61,10 @@ class Application_Model_Auth {
|
|||
$now = new DateTime();
|
||||
$token_life = new DateInterval(self::TOKEN_LIFETIME);
|
||||
$token_created = new DateTime($token_info->getDbCreated(), new DateTimeZone("UTC"));
|
||||
|
||||
|
||||
return $now->sub($token_life)->getTimestamp() < $token_created->getTimestamp();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the adapter for authentication against a database table
|
||||
*
|
||||
|
@ -79,10 +79,10 @@ class Application_Model_Auth {
|
|||
->setIdentityColumn('login')
|
||||
->setCredentialColumn('pass')
|
||||
->setCredentialTreatment('MD5(?)');
|
||||
|
||||
|
||||
return $authAdapter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get random string
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue