Skip to content

Commit 6803e53

Browse files
committed
Merge branch '3.2' into 'main'
2 parents 46b99f4 + 1348dce commit 6803e53

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

phpmyfaq/admin/assets/src/dashboard.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,25 @@ export const getLatestVersion = () => {
214214
if (response.ok) {
215215
const version = await response.json();
216216
loader.classList.add('d-none');
217-
versionText.insertAdjacentElement(
218-
'afterend',
219-
addElement('div', {
220-
classList: 'alert alert-success',
221-
innerText: version.success,
222-
})
223-
);
224-
} else {
225-
throw new Error('Network response was not ok: ', { cause: { response } });
217+
if (version.success) {
218+
versionText.insertAdjacentElement(
219+
'afterend',
220+
addElement('div', {
221+
classList: 'alert alert-success',
222+
innerText: version.success,
223+
})
224+
);
225+
} else {
226+
versionText.insertAdjacentElement(
227+
'afterend',
228+
addElement('div', {
229+
classList: 'alert alert-info',
230+
innerText: version.info,
231+
})
232+
);
233+
}
226234
}
235+
throw new Error('Network response was not ok: ', { cause: { response } });
227236
})
228237
.catch(async (error) => {
229238
const errorMessage = await error.cause.response;

phpmyfaq/api.service.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@
981981
break;
982982
}
983983

984+
$userId = Filter::filterVar($postData['userId'], FILTER_VALIDATE_INT);
984985
$author = trim((string) Filter::filterVar($postData['name'], FILTER_SANITIZE_SPECIAL_CHARS));
985986
$loginName = trim((string) Filter::filterVar($postData['loginname'], FILTER_SANITIZE_SPECIAL_CHARS));
986987
$email = trim((string) Filter::filterVar($postData['email'], FILTER_VALIDATE_EMAIL));
@@ -991,6 +992,19 @@
991992
$email = $faqConfig->getAdminEmail();
992993
}
993994

995+
// Validate User ID, Username and email
996+
$user = new User($faqConfig);
997+
if (
998+
!$user->getUserById($userId) ||
999+
$userId !== $user->getUserId() ||
1000+
$loginName !== $user->getLogin() ||
1001+
$email !== $user->getUserData('email')
1002+
) {
1003+
$response->setStatusCode(Response::HTTP_BAD_REQUEST);
1004+
$response->setData(['error' => Translation::get('ad_user_error_loginInvalid')]);
1005+
break;
1006+
}
1007+
9941008
if (!empty($author) && !empty($email) && !empty($question) && $stopWords->checkBannedWord($question)) {
9951009
$question = sprintf(
9961010
"%s %s\n%s %s\n%s %s\n\n %s",

phpmyfaq/assets/themes/default/templates/request-removal.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ <h1>{{ pageHeader }}</h1>
1818
</div>
1919

2020
<form id="formValues" action="#" method="post" class="needs-validation" novalidate>
21-
<input type="hidden" name="lang" id="lang" value="{{ lang }}" />
21+
<input type="hidden" name="lang" id="lang" value="{{ lang }}">
22+
<input type="hidden" name="userId" id="userId" value="{{ userId }}">
2223
{{ csrf }}
2324

2425
<div class="row mb-2">

phpmyfaq/request-removal.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
'ad_user_loginname' => Translation::get('ad_user_loginname'),
4848
'csrf' => Token::getInstance()->getTokenInput('request-removal'),
4949
'lang' => $Language->getLanguage(),
50+
'userId' => $user->getUserId(),
5051
'defaultContentMail' => ($user->getUserId() > 0) ? $user->getUserData('email') : '',
5152
'defaultContentName' =>
5253
($user->getUserId() > 0) ? Strings::htmlentities($user->getUserData('display_name')) : '',

0 commit comments

Comments
 (0)