29 lines
661 B
PHP
29 lines
661 B
PHP
|
<?php
|
||
|
|
||
|
// TODO: ...
|
||
|
class User
|
||
|
{
|
||
|
private Session $session;
|
||
|
|
||
|
public ?bool $loggedIn;
|
||
|
public ?string $username;
|
||
|
|
||
|
public function __construct(Session $session)
|
||
|
{
|
||
|
$this->session = $session;
|
||
|
|
||
|
$this->loggedIn = $this->session->get('loggedIn');
|
||
|
$this->username = $this->session->get('username');
|
||
|
}
|
||
|
|
||
|
public function login(string $username, string $password): bool
|
||
|
{
|
||
|
if ($username === 'William' && $password === 'William')
|
||
|
{
|
||
|
$this->session->set('loggedIn', TRUE);
|
||
|
$this->session->set('username', 'William');
|
||
|
return TRUE;
|
||
|
}
|
||
|
return FALSE;
|
||
|
}
|
||
|
}
|