mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-22 13:09:44 +05:30
Added newAuthCode function
This commit is contained in:
parent
fd90e76c91
commit
1c447e4a8e
@ -173,6 +173,52 @@ class Server
|
||||
return $params;
|
||||
}
|
||||
|
||||
public function newAuthCode(string $clientId, $type = 'user',
|
||||
string $typeId, string $redirectUri, $scopes = array(),
|
||||
string $access_token = null)
|
||||
{
|
||||
$authCode = $this->generateCode();
|
||||
|
||||
// Update an existing session with the new code
|
||||
if ($access_token !== null) {
|
||||
|
||||
$this->db->updateSession(
|
||||
$clientId,
|
||||
$type,
|
||||
$typeId,
|
||||
$authCode,
|
||||
$accessToken,
|
||||
'request'
|
||||
);
|
||||
|
||||
// Create a new oauth session
|
||||
} else {
|
||||
|
||||
// Delete any existing sessions just to be sure
|
||||
$this->db->deleteSession($clientId, $type, $typeId);
|
||||
|
||||
// Create a new session
|
||||
$sessionId = $this->db->newSession(
|
||||
$clientId,
|
||||
$redirectUri,
|
||||
$type,
|
||||
$typeId,
|
||||
$authCode,
|
||||
null,
|
||||
$stage = 'request'
|
||||
);
|
||||
|
||||
// Add the scopes
|
||||
foreach ($scopes as $scope)
|
||||
{
|
||||
$this->db->addSessionScope($sessionId, $scope);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $authCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the redirect uri with appended params
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user