Skip to content

Commit

Permalink
Merge pull request #34112 from nextcloud/backport/33819/stable24
Browse files Browse the repository at this point in the history
[stable24] Fix translation of user exists error server-side
  • Loading branch information
come-nc authored Sep 22, 2022
2 parents 85b5d72 + d864ea3 commit 6d81987
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/provisioning_api/lib/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public function addUser(

if ($this->userManager->userExists($userid)) {
$this->logger->error('Failed addUser attempt: User already exists.', ['app' => 'ocs_api']);
throw new OCSException('User already exists', 102);
throw new OCSException($this->l10nFactory->get('provisioning_api')->t('User already exists'), 102);
}

if ($groups !== []) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ public function testAddUserAlreadyExisting() {
->method('isAdmin')
->with('adminUser')
->willReturn(true);
$l10n = $this->createMock(IL10N::class);
$this->l10nFactory
->expects($this->once())
->method('get')
->with('provisioning_api')
->willReturn($l10n);

$this->api->addUser('AlreadyExistingUser', 'password', '', '', []);
}
Expand Down
8 changes: 0 additions & 8 deletions apps/settings/src/store/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import api from './api'
import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
import logger from '../logger'
import { showError } from '@nextcloud/dialogs'

const orderGroups = function(groups, orderBy) {
/* const SORT_USERCOUNT = 1;
Expand Down Expand Up @@ -553,13 +552,6 @@ const actions = {
.then((response) => dispatch('addUserData', userid || response.data.ocs.data.id))
.catch((error) => { throw error })
}).catch((error) => {
const statusCode = error?.response?.data?.ocs?.meta?.statuscode

if (statusCode === 102) {
showError(t('settings', 'User already exists.'))
throw error
}

commit('API_FAILURE', { userid, error })
throw error
})
Expand Down
Loading

0 comments on commit 6d81987

Please sign in to comment.