frontend, added user active flag, localization
This commit is contained in:
@@ -176,8 +176,9 @@ class Context {
|
||||
->addJoin(new InnerJoin("ApiKey", "ApiKey.user_id", "User.id"))
|
||||
->whereEq("ApiKey.api_key", $apiKey)
|
||||
->whereGt("valid_until", $this->sql->currentTimestamp())
|
||||
->whereTrue("ApiKey.active", true)
|
||||
->whereTrue("User.confirmed", true)
|
||||
->whereTrue("ApiKey.active")
|
||||
->whereTrue("User.confirmed")
|
||||
->whereTrue("User.active")
|
||||
->fetchEntities());
|
||||
|
||||
return $this->user !== null;
|
||||
|
||||
@@ -46,10 +46,16 @@ class Session extends DatabaseEntity {
|
||||
->whereEq("Session.uuid", $sessionUUID)
|
||||
->whereTrue("Session.active")
|
||||
->whereGt("Session.expires", $sql->now()));
|
||||
|
||||
if (!$session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$user = $session->getUser();
|
||||
if (!$user->isActive() || !$user->isConfirmed()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_array($session->data)) {
|
||||
foreach ($session->data as $key => $value) {
|
||||
$_SESSION[$key] = $value;
|
||||
|
||||
@@ -45,6 +45,10 @@ class User extends DatabaseEntity {
|
||||
#[DefaultValue(false)]
|
||||
public bool $confirmed;
|
||||
|
||||
#[Visibility(Visibility::BY_GROUP, Group::ADMIN, Group::SUPPORT)]
|
||||
#[DefaultValue(true)]
|
||||
public bool $active;
|
||||
|
||||
#[DefaultValue(Language::AMERICAN_ENGLISH)] public Language $language;
|
||||
|
||||
#[Visibility(Visibility::BY_GROUP, Group::ADMIN, Group::SUPPORT)]
|
||||
@@ -92,6 +96,14 @@ class User extends DatabaseEntity {
|
||||
return $this->profilePicture;
|
||||
}
|
||||
|
||||
public function isActive():bool {
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
public function isConfirmed():bool {
|
||||
return $this->confirmed;
|
||||
}
|
||||
|
||||
public function __debugInfo(): array {
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
|
||||
Reference in New Issue
Block a user