Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Controller/Backend/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ public function edit(): Response
/**
* @Route("/profile-edit", methods={"POST"}, name="bolt_profile_edit_post")
*/
public function save(ValidatorInterface $validator): Response
public function save(ValidatorInterface $validator, string $defaultLocale): Response
{
$this->validateCsrf('profileedit');

/** @var User $user */
$user = $this->getUser();
$displayName = $user->getDisplayName();
$locale = Json::findScalar($this->getFromRequest('locale'));
$locale = Json::findScalar($this->getFromRequest('locale')) ?: $defaultLocale;

$user->setDisplayName((string) $this->getFromRequest('displayName'));
$user->setEmail((string) $this->getFromRequest('email'));
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Backend/UserEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function delete(?User $user): Response
/**
* @Route("/user-edit/{id}", methods={"POST"}, name="bolt_user_edit_post", requirements={"id": "\d+"})
*/
public function save(?User $user, ValidatorInterface $validator): Response
public function save(?User $user, ValidatorInterface $validator, string $defaultLocale): Response
{
$this->validateCsrf('useredit');

Expand All @@ -144,9 +144,9 @@ public function save(?User $user, ValidatorInterface $validator): Response
}

$displayName = $user->getDisplayName();
$locale = Json::findScalar($this->getFromRequest('locale'));
$locale = Json::findScalar($this->getFromRequest('locale')) ?: $defaultLocale;
$roles = Json::findArray($this->getFromRequest('roles'));
$status = Json::findScalar($this->getFromRequest('ustatus', UserStatus::ENABLED));
$status = Json::findScalar($this->getFromRequest('ustatus')) ?: UserStatus::ENABLED;

if (empty($user->getUsername())) {
$user->setUsername($this->getFromRequest('username'));
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ Feature: Users & Permissions

Then I should be on "/bolt/user-edit/0"
And I should see "New User" in the ".admin__header--title" element

And I wait 0.1 seconds

When I fill in the following:
| username | test_user |
| displayName | Test user |
Expand Down Expand Up @@ -151,6 +152,7 @@ Feature: Users & Permissions
And I should see "Suggested secure password"

@javascript
@foo
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bobdenotter Oops... think we have to remove that! 🤪

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it! 🙈

Scenario: Edit my user with incorrect display name
Given I am logged in as "jane_admin" with password "jane%1"

Expand All @@ -162,9 +164,10 @@ Feature: Users & Permissions

And I should see "Jane Doe" in the "h1" element
And the field "username" should contain "jane_admin"

And I wait 0.1 seconds
When I fill "displayName" element with " "
And I scroll "Save changes" into view

And I press "Save changes"

Then I should see "Invalid display name"
Expand Down