summaryrefslogtreecommitdiff
path: root/src/application/mystic/forum/orm/User.php
blob: 97acbaf71bcec0914ced551bd580365bb5136d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
declare(strict_types=1);

namespace mystic\forum\orm;

use mystic\forum\attributes\Column;
use mystic\forum\attributes\PrimaryKey;
use mystic\forum\attributes\Table;
use mystic\forum\attributes\Unique;

#[Table("public.users")]
class User extends Entity {
    public const SUPERUSER_ID = "SUPERUSER";
    
    #[PrimaryKey]
    public string $id;
    #[Unique] public string $name;
    public string $displayName;
    #[Unique] public string $email;
    public \DateTimeImmutable $created;
    public string $passwordHash;
    public int $permissionMask;
    public bool $passwordResetRequired;
    public string $activationToken;
    public bool $activated;
    #[Column(columnType: "bytea")] public ?string $profilePicture;
    public ?\DateTimeImmutable $nameLastChanged;

    public function hasPermission(int $perm): bool {
        if ($this->id === self::SUPERUSER_ID)
            return true;
        return ($this->permissionMask & $perm) === $perm;
    }
}