Skip to content
This repository was archived by the owner on Jul 10, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions src/OAuth2/Storage/AetStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class AetStorage implements
AccessTokenInterface,
ClientCredentialsInterface,
ClientCredentialsInterface,
UserCredentialsInterface
{
protected $db;
Expand All @@ -27,7 +27,7 @@ public function __construct($config = array())


$connection = array('dsn' => $dsn, 'username' => $username, 'password' => $password);

if (!$connection instanceof \PDO) {
if (is_string($connection)) {
$connection = array('dsn' => $connection);
Expand Down Expand Up @@ -56,7 +56,7 @@ public function __construct($config = array())
'access_token_table' => 'oauth_access_tokens',
'refresh_token_table' => 'oauth_refresh_tokens',
'code_table' => 'oauth_authorization_codes',
'user_table' => 'web_ira',
'user_table' => 'users',
'jwt_table' => 'oauth_jwt',
'jti_table' => 'oauth_jti',
'scope_table' => 'oauth_scopes',
Expand Down Expand Up @@ -295,19 +295,18 @@ public function unsetRefreshToken($refresh_token)
// plaintext passwords are bad! Override this for your application
protected function checkPassword($user, $password)
{
// return $user['password'] == sha1($password);
return $user['password'] == $password;
return password_verify($password, $user['password']);
}

public function getUser($username)
{
$params = array(
'username' => $username
);

$this->ci_ira_model->fxconnect();
$fxuser = $this->ci_ira_model->fxquery('web_ira', $params, 1);

if($fxuser){
// Oauth TokenController required user_id field
$fxuser[0]['user_id'] = $fxuser[0]['username'];
Expand All @@ -327,8 +326,8 @@ public function tempGetUser($username)
return array_merge(array(
'user_id' => $username
), $userInfo);
}
}

public function setUser($username, $password, $firstName = null, $lastName = null)
{
// do not store in plaintext
Expand Down Expand Up @@ -458,20 +457,20 @@ public function getEncryptionAlgorithm($client_id = null)
}

public function delete_user_access_tokens($user_id){

$sql = "DELETE FROM oauth_access_tokens WHERE user_id = :user_id";
$stmt = $this->db->prepare($sql);
$stmt->bindParam(':user_id', $user_id);
$stmt->bindParam(':user_id', $user_id);
$stmt->execute();

}

public function delete_expired_access_tokens(){
$sql = "DELETE FROM oauth_access_tokens WHERE expire < now()";
$stmt = $this->db->prepare($sql);
$stmt = $this->db->prepare($sql);
$stmt->execute();
}

/**
* DDL to create OAuth2 database and tables for PDO storage
*
Expand Down Expand Up @@ -559,4 +558,4 @@ public function getBuildSql($dbName = 'oauth2_server_php')

return $sql;
}
}
}