Skip to content

Commit

Permalink
fix: let WebAuthn user edit their name
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Sep 13, 2024
1 parent 641cd35 commit 6fb0fa2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
3 changes: 2 additions & 1 deletion phpmyfaq/admin/assets/src/content/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @since 2022-01-31
*/

// TinyMCE global which is used to init the editor
// TinyMCE global, which is used to init the editor
import tinymce from 'tinymce/tinymce';
import 'tinymce/models/dom';

Expand Down Expand Up @@ -88,6 +88,7 @@ export const renderEditor = () => {
extended_valid_elements: 'code[class],video[*],audio[*],source[*]',
removeformat: [{ selector: '*', attributes: ['style'], split: false, expand: false, deep: true }],
importcss_append: true,
sandbox_iframes: true,

// Font handling
fontsize_formats: '6pt 8pt 9pt 10pt 11pt 12pt 14pt 16pt 18pt 20pt 24pt 36pt 48pt',
Expand Down
1 change: 0 additions & 1 deletion phpmyfaq/assets/templates/default/ucp.twig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
value="{{ realname|raw }}"
class="form-control"
required
{{ readonly }}
/>
</div>
</div>
Expand Down
23 changes: 15 additions & 8 deletions phpmyfaq/src/phpMyFAQ/Controller/Frontend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function updateData(Request $request): JsonResponse
$twoFactorEnabled = Filter::filterVar($data->twofactor_enabled ?? 'off', FILTER_SANITIZE_SPECIAL_CHARS);

$isAzureAdUser = $user->getUserAuthSource() === 'azure';

$isWebAuthnUser = $user->getUserAuthSource() === 'webauthn';

if ($userId !== $user->getUserId()) {
return $this->json(['error' => 'User ID mismatch!'], Response::HTTP_BAD_REQUEST);
Expand All @@ -77,15 +77,22 @@ public function updateData(Request $request): JsonResponse
);
}

if (strlen($password) <= 7 || strlen($confirm) <= 7) {
if ((strlen($password) <= 7 || strlen($confirm) <= 7) && !$isWebAuthnUser) {
return $this->json(['error' => Translation::get('ad_passwd_fail')], Response::HTTP_CONFLICT);
} else {
$userData = [
'display_name' => $userName,
'email' => $email,
'is_visible' => $isVisible === 'on' ? 1 : 0,
'twofactor_enabled' => $twoFactorEnabled === 'on' ? 1 : 0
];
if ($isWebAuthnUser) {
$userData = [
'display_name' => $userName,
'is_visible' => $isVisible === 'on' ? 1 : 0,
];
} else {
$userData = [
'display_name' => $userName,
'email' => $email,
'is_visible' => $isVisible === 'on' ? 1 : 0,
'twofactor_enabled' => $twoFactorEnabled === 'on' ? 1 : 0
];
}

$success = $user->setUserData($userData);

Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/Permission/BasicPermission.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function getAllUserRights(int $userId): array
*/
public function getUserRightsCount(CurrentUser $currentUser): int
{
$userRights = $this->getAllUserRights($currentUser->getUserId());
$userRights = $this->getUserRights($currentUser->getUserId());

return is_countable($userRights) ? count($userRights) : 0;
}
Expand Down

0 comments on commit 6fb0fa2

Please sign in to comment.