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
1 change: 1 addition & 0 deletions lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public function create(string $email, string $displayName, string $language, arr
'message' => $this->l10n->t(
'User successfully created'
),
'username' => $username,
],
Http::STATUS_CREATED
);
Expand Down
15 changes: 5 additions & 10 deletions src/views/GuestForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,7 @@ export default {

watch: {
'guest.email': function() {
if (this.guest.email) {
this.guest.username = this.guest.email
} else {
this.guest.username = ''
}

this.$nextTick(() => {
this.resetErrors()
})
this.resetErrors()
},
},

Expand Down Expand Up @@ -233,13 +225,16 @@ export default {

this.loading = true
try {
await axios.put(generateOcsUrl('/apps/guests/api/v1/users'), {
const { data } = await axios.put(generateOcsUrl('/apps/guests/api/v1/users'), {
displayName: this.guest.fullName,
email: this.guest.email,
language: this.guest.language,
groups: this.guest.groups,
})

// ensure the username is set - we do not know it in advance as it is generated by the backend
this.guest.username = data.ocs.data.username

if (this.integrationApp === 'files') {
await this.setupGuestShare()
return
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/Controller/UsersControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,10 @@ public function testCreateSuccessWithGroupsAsSubadmin(): void {

$response = $this->controller->create('new@example.com', 'Test User', 'en', ['group1', 'group2']);
$this->assertEquals(Http::STATUS_CREATED, $response->getStatus());
$this->assertEquals(['message' => 'User successfully created'], $response->getData());
$this->assertEquals([
'message' => 'User successfully created',
'username' => 'new@example.com',
], $response->getData());
}

/**
Expand Down
Loading