mirror of
https://github.com/grocy/grocy.git
synced 2025-10-14 17:24:07 +00:00
Revise session handling to prepare API authentication via token
This commit is contained in:
@@ -24,11 +24,11 @@ class SessionService extends BaseService
|
||||
*/
|
||||
public function CreateSession()
|
||||
{
|
||||
$newSessionKey = uniqid() . uniqid() . uniqid();
|
||||
$newSessionKey = $this->GenerateSessionKey();
|
||||
|
||||
$sessionRow = $this->Database->sessions()->createRow(array(
|
||||
'session_key' => $newSessionKey,
|
||||
'expires' => time() + 2592000 //30 days
|
||||
'expires' => time() + 2592000 // 30 days
|
||||
));
|
||||
$sessionRow->save();
|
||||
|
||||
@@ -39,4 +39,9 @@ class SessionService extends BaseService
|
||||
{
|
||||
$this->Database->sessions()->where('session_key', $sessionKey)->delete();
|
||||
}
|
||||
|
||||
private function GenerateSessionKey()
|
||||
{
|
||||
return RandomString(50);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user