mirror of
https://github.com/grocy/grocy.git
synced 2025-08-19 03:40:10 +00:00
Replace the single user (defined in /data/config.php) with a multi user management thing
This commit is contained in:
@@ -33,11 +33,12 @@ class SessionService extends BaseService
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function CreateSession()
|
||||
public function CreateSession($userId)
|
||||
{
|
||||
$newSessionKey = $this->GenerateSessionKey();
|
||||
|
||||
$sessionRow = $this->Database->sessions()->createRow(array(
|
||||
'user_id' => $userId,
|
||||
'session_key' => $newSessionKey,
|
||||
'expires' => date('Y-m-d H:i:s', time() + 2592000) // Default is that sessions expire in 30 days
|
||||
));
|
||||
@@ -51,6 +52,16 @@ class SessionService extends BaseService
|
||||
$this->Database->sessions()->where('session_key', $sessionKey)->delete();
|
||||
}
|
||||
|
||||
public function GetUserBySessionKey($sessionKey)
|
||||
{
|
||||
$sessionRow = $this->Database->sessions()->where('session_key', $sessionKey)->fetch();
|
||||
if ($sessionRow !== null)
|
||||
{
|
||||
return $this->Database->users($sessionRow->user_id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function GenerateSessionKey()
|
||||
{
|
||||
return RandomString(50);
|
||||
|
Reference in New Issue
Block a user