fix: getting user id
This commit is contained in:
parent
1fc8f31d38
commit
0f16293f4e
10 changed files with 23 additions and 23 deletions
|
@ -62,7 +62,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
:wishlist_id
|
:wishlist_id
|
||||||
);',
|
);',
|
||||||
array(
|
array(
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->getId(),
|
||||||
'wishlist_id' => Sanitiser::getNumber($_POST['wishlist']),
|
'wishlist_id' => Sanitiser::getNumber($_POST['wishlist']),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,11 +14,11 @@ $user = User::getCurrent();
|
||||||
|
|
||||||
switch ($_SERVER['REQUEST_METHOD']) {
|
switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
case 'POST':
|
case 'POST':
|
||||||
if (isset($_POST['wishlist-name'], $user->id)) {
|
if (isset($_POST['wishlist-name'], $user->getId())) {
|
||||||
/**
|
/**
|
||||||
* Create
|
* Create
|
||||||
*/
|
*/
|
||||||
$user_id = Sanitiser::getNumber($user->id);
|
$user_id = Sanitiser::getNumber($user->getId());
|
||||||
$wishlist_name = Sanitiser::getTitle($_POST['wishlist-name']);
|
$wishlist_name = Sanitiser::getTitle($_POST['wishlist-name']);
|
||||||
$wishlist_hash = sha1(time() . $user_id . $wishlist_name);
|
$wishlist_hash = sha1(time() . $user_id . $wishlist_name);
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
|
|
||||||
if ($wishlist->exists) {
|
if ($wishlist->exists) {
|
||||||
/** Determine if user is allowed to access wishlist */
|
/** Determine if user is allowed to access wishlist */
|
||||||
if ($user->isLoggedIn() && $user->id === $wishlist->user) {
|
if ($user->isLoggedIn() && $user->getId() === $wishlist->user) {
|
||||||
$response['results'] = $wishlist;
|
$response['results'] = $wishlist;
|
||||||
} else {
|
} else {
|
||||||
http_response_code(403);
|
http_response_code(403);
|
||||||
|
@ -155,7 +155,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
|
||||||
} else {
|
} else {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
}
|
}
|
||||||
} elseif (isset($_GET['userid']) || isset($user->id)) {
|
} elseif (isset($_GET['userid']) || isset($user->getId())) {
|
||||||
/**
|
/**
|
||||||
* Get user wishlists
|
* Get user wishlists
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -457,6 +457,10 @@ class User
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getId(): int {
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
public function getEmail(): string {
|
public function getEmail(): string {
|
||||||
return $this->email;
|
return $this->email;
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ class Wish
|
||||||
$userCard->getLocale() . '@currency=' . $userCard->getCurrency(),
|
$userCard->getLocale() . '@currency=' . $userCard->getCurrency(),
|
||||||
\NumberFormatter::CURRENCY
|
\NumberFormatter::CURRENCY
|
||||||
);
|
);
|
||||||
$userIsCurrent = isset($userCurrent->id) && $userCurrent->id === $userCard->id;
|
$userIsCurrent = isset($userCurrent->getId()) && $userCurrent->getId() === $userCard->getId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Card
|
* Card
|
||||||
|
|
|
@ -49,7 +49,7 @@ $user = User::getCurrent();
|
||||||
ORDER BY `wishes`.`edited` DESC
|
ORDER BY `wishes`.`edited` DESC
|
||||||
LIMIT 1;',
|
LIMIT 1;',
|
||||||
array(
|
array(
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->getId(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ if (isset($_POST['reset'], $_POST['email'])) {
|
||||||
|
|
||||||
$user = false !== $userQuery ? new User($userQuery->fetch()) : new User();
|
$user = false !== $userQuery ? new User($userQuery->fetch()) : new User();
|
||||||
|
|
||||||
if (isset($user->id)) {
|
if (isset($user->getId())) {
|
||||||
$token = sha1(time() . rand(0, 999999));
|
$token = sha1(time() . rand(0, 999999));
|
||||||
$validUntil = time() + 3600;
|
$validUntil = time() + 3600;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ if (isset($_POST['reset'], $_POST['email'])) {
|
||||||
'UPDATE `users`
|
'UPDATE `users`
|
||||||
SET `password_reset_token` = :user_password_reset_token,
|
SET `password_reset_token` = :user_password_reset_token,
|
||||||
`password_reset_valid_until` = :user_reset_valid_until
|
`password_reset_valid_until` = :user_reset_valid_until
|
||||||
WHERE `id` = ' . $user->id . ';',
|
WHERE `id` = ' . $user->getId() . ';',
|
||||||
array(
|
array(
|
||||||
'user_password_reset_token' => $token,
|
'user_password_reset_token' => $token,
|
||||||
'user_reset_valid_until' => date('Y-m-d H:i:s', $validUntil),
|
'user_reset_valid_until' => date('Y-m-d H:i:s', $validUntil),
|
||||||
|
|
|
@ -10,7 +10,7 @@ $user = User::getCurrent();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php if ($user->isLoggedIn()) { ?>
|
<?php if ($user->isLoggedIn()) { ?>
|
||||||
<input type="hidden" name="user-id" value="<?= $user->id ?>" />
|
<input type="hidden" name="user-id" value="<?= $user->getId() ?>" />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<div class="wishlist-filter-wrapper">
|
<div class="wishlist-filter-wrapper">
|
||||||
|
|
|
@ -218,7 +218,7 @@ $page->navigation();
|
||||||
|
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<form class="ui form" method="POST">
|
<form class="ui form" method="POST">
|
||||||
<input type="hidden" name="user-id" value="<?= $user->id ?>" />
|
<input type="hidden" name="user-id" value="<?= $user->getId() ?>" />
|
||||||
<input type="hidden" name="section" value="personal" />
|
<input type="hidden" name="section" value="personal" />
|
||||||
|
|
||||||
<div class="three fields">
|
<div class="three fields">
|
||||||
|
@ -284,7 +284,7 @@ $page->navigation();
|
||||||
|
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<form class="ui form" method="POST">
|
<form class="ui form" method="POST">
|
||||||
<input type="hidden" name="user-id" value="<?= $user->id ?>" />
|
<input type="hidden" name="user-id" value="<?= $user->getId() ?>" />
|
||||||
<input type="hidden" name="section" value="password" />
|
<input type="hidden" name="section" value="password" />
|
||||||
|
|
||||||
<div class="two fields">
|
<div class="two fields">
|
||||||
|
@ -347,7 +347,7 @@ $page->navigation();
|
||||||
|
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<form class="ui form" method="POST">
|
<form class="ui form" method="POST">
|
||||||
<input type="hidden" name="user-id" value="<?= $user->id ?>" />
|
<input type="hidden" name="user-id" value="<?= $user->getId() ?>" />
|
||||||
<input type="hidden" name="section" value="preferences" />
|
<input type="hidden" name="section" value="preferences" />
|
||||||
|
|
||||||
<div class="two fields">
|
<div class="two fields">
|
||||||
|
@ -447,7 +447,7 @@ $page->navigation();
|
||||||
|
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<form class="ui form" method="POST">
|
<form class="ui form" method="POST">
|
||||||
<input type="hidden" name="user-id" value="<?= $user->id ?>" />
|
<input type="hidden" name="user-id" value="<?= $user->getId() ?>" />
|
||||||
<input type="hidden" name="section" value="preferences" />
|
<input type="hidden" name="section" value="preferences" />
|
||||||
|
|
||||||
<?php if (defined('CHANNELS') && is_array(CHANNELS)) { ?>
|
<?php if (defined('CHANNELS') && is_array(CHANNELS)) { ?>
|
||||||
|
@ -512,17 +512,13 @@ $page->navigation();
|
||||||
|
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<form class="ui form" method="POST">
|
<form class="ui form" method="POST">
|
||||||
<input type="hidden" name="user-id" value="<?= $user->id ?>" />
|
<input type="hidden" name="user-id" value="<?= $user->getId() ?>" />
|
||||||
<input type="hidden" name="section" value="preferences" />
|
<input type="hidden" name="section" value="preferences" />
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label><?= __('Advertisements') ?></label>
|
<label><?= __('Advertisements') ?></label>
|
||||||
|
|
||||||
<div class="ui toggle checkbox advertisements">
|
<div class="ui toggle checkbox advertisements">
|
||||||
<?php
|
|
||||||
$user = isset($user->id) ? $user : new User();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php if (true === $user->advertisements) { ?>
|
<?php if (true === $user->advertisements) { ?>
|
||||||
<input type="checkbox" name="enable-advertisements" checked="checked" />
|
<input type="checkbox" name="enable-advertisements" checked="checked" />
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
|
@ -563,7 +559,7 @@ $page->navigation();
|
||||||
|
|
||||||
<div class="ui segment">
|
<div class="ui segment">
|
||||||
<form class="ui form" method="POST">
|
<form class="ui form" method="POST">
|
||||||
<input type="hidden" name="user-id" value="<?= $user->id ?>" />
|
<input type="hidden" name="user-id" value="<?= $user->getId() ?>" />
|
||||||
<input type="hidden" name="section" value="account" />
|
<input type="hidden" name="section" value="account" />
|
||||||
|
|
||||||
<div class="field">
|
<div class="field">
|
||||||
|
|
|
@ -93,7 +93,7 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||||
WHERE `id` = :user_id;',
|
WHERE `id` = :user_id;',
|
||||||
array(
|
array(
|
||||||
'user_password' => User::passwordToHash($_POST['password']),
|
'user_password' => User::passwordToHash($_POST['password']),
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->getId(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ $user = User::getCurrent();
|
||||||
<div class="ui stackable grid">
|
<div class="ui stackable grid">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
|
||||||
<?php if ($user->isLoggedIn() && $user->id !== $wishlist->user) { ?>
|
<?php if ($user->isLoggedIn() && $user->getId() !== $wishlist->user) { ?>
|
||||||
<button class="ui white small basic labeled icon button save disabled loading">
|
<button class="ui white small basic labeled icon button save disabled loading">
|
||||||
<i class="heart icon"></i>
|
<i class="heart icon"></i>
|
||||||
<span><?= __('Remember list') ?></span>
|
<span><?= __('Remember list') ?></span>
|
||||||
|
@ -49,7 +49,7 @@ $user = User::getCurrent();
|
||||||
/**
|
/**
|
||||||
* Warn the wishlist creator
|
* Warn the wishlist creator
|
||||||
*/
|
*/
|
||||||
if ($user->isLoggedIn() && $user->id === $wishlist->user) { ?>
|
if ($user->isLoggedIn() && $user->getId() === $wishlist->user) { ?>
|
||||||
<div class="ui icon warning message wishlist-own">
|
<div class="ui icon warning message wishlist-own">
|
||||||
<i class="exclamation triangle icon"></i>
|
<i class="exclamation triangle icon"></i>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
Loading…
Reference in a new issue