Skip to content

Commit aca0663

Browse files
committed
Merge branch '3.2' into 'main'
2 parents cb373dd + 638b1a9 commit aca0663

File tree

6 files changed

+14
-11
lines changed

6 files changed

+14
-11
lines changed

phpmyfaq/admin/category.edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class="form-check-input" <?= ($allUsers ? 'checked' : '') ?>>
209209
</label>
210210
</div>
211211
<select name="restricted_users" id="restricted_users" class="form-select">
212-
<?= $userHelper->getAllUserOptions($userPermission[0]) ?>
212+
<?= $userHelper->getAllUserOptions($categoryData->getUserId()) ?>
213213
</select>
214214
</div>
215215
</div>

phpmyfaq/index.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
//
145145
// Validating token from 2FA if given; else: returns error message
146146
//
147-
if ($token !== '' && $userid !== '') {
147+
if ($token !== '' && !is_null($userid)) {
148148
if (strlen((string) $token) === 6 && is_numeric((string) $token)) {
149149
$user = new CurrentUser($faqConfig);
150150
$user->getUserById($userid);
@@ -185,7 +185,7 @@
185185

186186
if (isset($userAuth)) {
187187
if ($userAuth instanceof UserAuthentication) {
188-
if ($userAuth->hasTwoFactorAuthentication() === true) {
188+
if ($userAuth->hasTwoFactorAuthentication()) {
189189
$action = 'twofactor';
190190
}
191191
}

phpmyfaq/src/phpMyFAQ/Category.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public function getGroups(): array
145145
*
146146
* @param bool $withPermission With or without permission check
147147
*/
148-
public function getOrderedCategories(bool $withPermission = true): array
148+
public function getOrderedCategories(bool $withPermission = true, bool $withInactive = false): array
149149
{
150150
$categories = [];
151151
$where = '';
@@ -157,11 +157,11 @@ public function getOrderedCategories(bool $withPermission = true): array
157157
( fg.group_id IN (%s)
158158
OR
159159
(fu.user_id = %d AND fg.group_id IN (%s)))
160-
AND
161-
fc.active = 1',
160+
%s',
162161
implode(', ', $this->groups),
163162
$this->user,
164-
implode(', ', $this->groups)
163+
implode(', ', $this->groups),
164+
$withInactive ? '' : 'AND fc.active = 1'
165165
);
166166
}
167167

@@ -1180,6 +1180,7 @@ public function getMissingCategories(): void
11801180
$query .= " WHERE lang != '" . $this->language . "'";
11811181
}
11821182
$query .= ' ORDER BY id';
1183+
11831184
$result = $this->config->getDb()->query($query);
11841185
while ($row = $this->config->getDb()->fetchArray($result)) {
11851186
if (!array_key_exists($row['id'], $this->categoryName)) {

phpmyfaq/src/phpMyFAQ/User/CurrentUser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public function login(string $login, string $password): bool
186186
$this->getUserByLogin($login);
187187

188188
// only save this successful login to session when 2FA is not enabled
189-
if ($this->getUserData('twofactor_enabled') !== 1) {
189+
if ((int)$this->getUserData('twofactor_enabled') !== 1) {
190190
$this->setLoggedIn(true);
191191
$this->updateSessionId(true);
192192
$this->saveToSession();
@@ -210,7 +210,7 @@ public function login(string $login, string $password): bool
210210
}
211211

212212
// Login successful if 2FA is not enabled
213-
if ($this->getUserData('twofactor_enabled') !== 1) {
213+
if ((int)$this->getUserData('twofactor_enabled') !== 1) {
214214
$this->setSuccess(true);
215215
}
216216

phpmyfaq/src/phpMyFAQ/User/TwoFactor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ public function validateToken(string $token, int $userid): bool
9393

9494
/**
9595
* Returns a QR-Code to a given secret for transmitting the secret to the Authenticator-App
96+
*
97+
* @throws TwoFactorAuthException
9698
*/
9799
public function getQrCode(string $secret): string
98100
{
99-
$user = CurrentUser::getFromSession($this->config);
101+
$user = CurrentUser::getCurrentUser($this->config);
100102
$label = $this->config->getTitle() . ':' . $user->getUserData('email');
101103
$qrCodeText = $this->twoFactorAuth->getQrText($label, $secret) . '&image=' . $this->config->getDefaultUrl() .
102104
'assets/themes/' . Template::getTplSetName() . '/img/logo.png';

phpmyfaq/src/phpMyFAQ/User/UserAuthentication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function authenticate(string $username, string $password): CurrentUser
8787

8888
// Local
8989
if ($this->user->login($username, $password)) {
90-
if ($this->user->getUserData('twofactor_enabled') == 1) {
90+
if ($this->user->getUserData('twofactor_enabled')) {
9191
$this->setTwoFactorAuthentication(true);
9292
$this->user->setLoggedIn(false);
9393
} else {

0 commit comments

Comments
 (0)