Compare commits
4 Commits
79509135b7
...
71aed9dcec
Author | SHA1 | Date | |
---|---|---|---|
71aed9dcec | |||
b809542083 | |||
749b93e3af | |||
df3bf89079 |
@ -0,0 +1,5 @@
|
|||||||
|
ALTER TABLE `users`
|
||||||
|
ADD `full_name` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
ADD `nickname` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
ADD `phone` varchar(255) NOT NULL DEFAULT '',
|
||||||
|
ADD `id_number` varchar(255) NOT NULL DEFAULT '';
|
@ -106,7 +106,12 @@ class OAuthLoginController
|
|||||||
'exp' => (int)$token->getExpiresDate()->format('U'),
|
'exp' => (int)$token->getExpiresDate()->format('U'),
|
||||||
'nonce' => $token->getNonce(),
|
'nonce' => $token->getNonce(),
|
||||||
'sub' => $user->getId(),
|
'sub' => $user->getId(),
|
||||||
'email' => $user->getEmail()
|
'email' => $user->getEmail(),
|
||||||
|
'username' => $user->getUsername(),
|
||||||
|
'full_name' => $user->getFullName(),
|
||||||
|
'nickname' => $user->getNickname(),
|
||||||
|
'phone' => $user->getPhone(),
|
||||||
|
'id_number' => $user->getIdNumber()
|
||||||
];
|
];
|
||||||
$privateKey = file_get_contents(ROOT . '/' . $_ENV['JWT_RSA_PRIVATE_KEY']);
|
$privateKey = file_get_contents(ROOT . '/' . $_ENV['JWT_RSA_PRIVATE_KEY']);
|
||||||
$jwt = JWT::encode($payload, $privateKey, 'RS256');
|
$jwt = JWT::encode($payload, $privateKey, 'RS256');
|
||||||
|
@ -181,6 +181,10 @@ class UserController implements ISecured
|
|||||||
$user->setPlainPassword($newPassword);
|
$user->setPlainPassword($newPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$user->setNickname($this->request->post('nickname'));
|
||||||
|
$user->setPhone($this->request->post('phone'));
|
||||||
|
$user->setIdNumber($this->request->post('id_number'));
|
||||||
|
|
||||||
$this->pdm->saveToDb($user);
|
$this->pdm->saveToDb($user);
|
||||||
|
|
||||||
$this->request->session()->delete('authenticated_with_google_until');
|
$this->request->session()->delete('authenticated_with_google_until');
|
||||||
|
@ -8,7 +8,7 @@ class User extends Model implements IUser
|
|||||||
{
|
{
|
||||||
protected static string $table = 'users';
|
protected static string $table = 'users';
|
||||||
|
|
||||||
protected static array $fields = ['email', 'username', 'password', 'type', 'google_sub', 'created'];
|
protected static array $fields = ['email', 'username', 'password', 'type', 'google_sub', 'created', 'full_name', 'nickname', 'phone', 'id_number'];
|
||||||
|
|
||||||
private static array $types = ['user', 'admin'];
|
private static array $types = ['user', 'admin'];
|
||||||
|
|
||||||
@ -24,6 +24,14 @@ class User extends Model implements IUser
|
|||||||
|
|
||||||
private DateTime $created;
|
private DateTime $created;
|
||||||
|
|
||||||
|
private string $fullName = '';
|
||||||
|
|
||||||
|
private string $nickname = '';
|
||||||
|
|
||||||
|
private string $phone = '';
|
||||||
|
|
||||||
|
private string $idNumber = '';
|
||||||
|
|
||||||
public function setEmail(string $email): void
|
public function setEmail(string $email): void
|
||||||
{
|
{
|
||||||
$this->email = $email;
|
$this->email = $email;
|
||||||
@ -66,6 +74,26 @@ class User extends Model implements IUser
|
|||||||
$this->created = new DateTime($created);
|
$this->created = new DateTime($created);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setFullName(string $fullName): void
|
||||||
|
{
|
||||||
|
$this->fullName = $fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNickname(string $nickname): void
|
||||||
|
{
|
||||||
|
$this->nickname = $nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPhone(string $phone): void
|
||||||
|
{
|
||||||
|
$this->phone = $phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setIdNumber(string $idNumber): void
|
||||||
|
{
|
||||||
|
$this->idNumber = $idNumber;
|
||||||
|
}
|
||||||
|
|
||||||
public function getEmail(): string
|
public function getEmail(): string
|
||||||
{
|
{
|
||||||
return $this->email;
|
return $this->email;
|
||||||
@ -101,6 +129,26 @@ class User extends Model implements IUser
|
|||||||
return $this->created->format('Y-m-d H:i:s');
|
return $this->created->format('Y-m-d H:i:s');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFullName(): string
|
||||||
|
{
|
||||||
|
return $this->fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNickname(): string
|
||||||
|
{
|
||||||
|
return $this->nickname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPhone(): string
|
||||||
|
{
|
||||||
|
return $this->phone;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIdNumber(): string
|
||||||
|
{
|
||||||
|
return $this->idNumber;
|
||||||
|
}
|
||||||
|
|
||||||
public function hasPermission(int $permission): bool
|
public function hasPermission(int $permission): bool
|
||||||
{
|
{
|
||||||
switch ($permission) {
|
switch ($permission) {
|
||||||
@ -120,7 +168,7 @@ class User extends Model implements IUser
|
|||||||
|
|
||||||
public function getDisplayName(): string
|
public function getDisplayName(): string
|
||||||
{
|
{
|
||||||
return $this->email;
|
return $this->nickname ?: $this->fullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkPassword(string $password): bool
|
public function checkPassword(string $password): bool
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
@section(main)
|
@section(main)
|
||||||
<h2>Account</h2>
|
<h2>Account</h2>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<form id="accountForm" action="/account" method="post" data-observe-inputs="email,username,password_new,password_new_confirm">
|
<form id="accountForm" action="/account" method="post" data-reload-on-success="true" data-observe-inputs="email,username,password_new,password_new_confirm,nickname,phone,id_number">
|
||||||
<?php if ($user['password'] !== null && $user['google_sub'] !== null): ?>
|
<?php if ($user['password'] !== null && $user['google_sub'] !== null): ?>
|
||||||
<p class="justify small">Please confirm your identity with your password or with Google to modify your account.</p>
|
<p class="justify small">Please confirm your identity with your password or with Google to modify your account.</p>
|
||||||
<div class="inputWithButton">
|
<div class="inputWithButton">
|
||||||
@ -27,6 +27,11 @@
|
|||||||
<input type="text" class="text big fullWidth marginTop" name="username" placeholder="Username" value="<?= $user['username'] ?>">
|
<input type="text" class="text big fullWidth marginTop" name="username" placeholder="Username" value="<?= $user['username'] ?>">
|
||||||
<input type="password" class="text big fullWidth marginTop" name="password_new" placeholder="New password" minlength="6">
|
<input type="password" class="text big fullWidth marginTop" name="password_new" placeholder="New password" minlength="6">
|
||||||
<input type="password" class="text big fullWidth marginTop" name="password_new_confirm" placeholder="New password confirmation" minlength="6">
|
<input type="password" class="text big fullWidth marginTop" name="password_new_confirm" placeholder="New password confirmation" minlength="6">
|
||||||
|
<hr>
|
||||||
|
<input type="text" class="text big fullWidth marginTop" name="full_name" placeholder="Full name" value="<?= $user['full_name'] ?>" disabled>
|
||||||
|
<input type="text" class="text big fullWidth marginTop" name="nickname" placeholder="Nickname" value="<?= $user['nickname'] ?>">
|
||||||
|
<input type="text" class="text big fullWidth marginTop" name="phone" placeholder="Phone" value="<?= $user['phone'] ?>">
|
||||||
|
<input type="text" class="text big fullWidth marginTop" name="id_number" placeholder="ID number" value="<?= $user['id_number'] ?>">
|
||||||
<p id="accountFormError" class="formError justify marginTop"></p>
|
<p id="accountFormError" class="formError justify marginTop"></p>
|
||||||
<div class="right marginTop">
|
<div class="right marginTop">
|
||||||
<button type="submit" name="submit" disabled>Save</button>
|
<button type="submit" name="submit" disabled>Save</button>
|
||||||
|
Loading…
Reference in New Issue
Block a user