summaryrefslogtreecommitdiff
path: root/src/application/mystic/forum/orm/User.php
blob: 1db1d04e872e7b613624096d6669679c2992b2aa (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
<?php
declare(strict_types=1);

namespace mystic\forum\orm;

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;

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