mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
Closes #169 feedback for username/group name already taken
This commit is contained in:
parent
4cc3fa4d89
commit
cf44af0065
@ -114,7 +114,7 @@ public class UserResource extends BaseResource {
|
|||||||
userDao.create(user, principal.getId());
|
userDao.create(user, principal.getId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if ("AlreadyExistingUsername".equals(e.getMessage())) {
|
if ("AlreadyExistingUsername".equals(e.getMessage())) {
|
||||||
throw new ServerException("AlreadyExistingUsername", "Login already used", e);
|
throw new ClientException("AlreadyExistingUsername", "Login already used", e);
|
||||||
} else {
|
} else {
|
||||||
throw new ServerException("UnknownError", "Unknown server error", e);
|
throw new ServerException("UnknownError", "Unknown server error", e);
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,13 @@ angular.module('docs').controller('SettingsGroupEdit', function($scope, $dialog,
|
|||||||
// Go to edit this group to add members
|
// Go to edit this group to add members
|
||||||
$state.go('settings.group.edit', { name: group.name });
|
$state.go('settings.group.edit', { name: group.name });
|
||||||
}
|
}
|
||||||
|
}, function (e) {
|
||||||
|
if (e.data.type === 'GroupAlreadyExists') {
|
||||||
|
var title = $translate.instant('settings.group.edit.edit_group_failed_title');
|
||||||
|
var msg = $translate.instant('settings.group.edit.edit_group_failed_message');
|
||||||
|
var btns = [{result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'}];
|
||||||
|
$dialog.messageBox(title, msg, btns);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,6 +42,13 @@ angular.module('docs').controller('SettingsUserEdit', function($scope, $dialog,
|
|||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
$scope.loadUsers();
|
$scope.loadUsers();
|
||||||
$state.go('settings.user');
|
$state.go('settings.user');
|
||||||
|
}, function (e) {
|
||||||
|
if (e.data.type === 'AlreadyExistingUsername') {
|
||||||
|
var title = $translate.instant('settings.user.edit.edit_user_failed_title');
|
||||||
|
var msg = $translate.instant('settings.user.edit.edit_user_failed_message');
|
||||||
|
var btns = [{result: 'ok', label: $translate.instant('ok'), cssClass: 'btn-primary'}];
|
||||||
|
$dialog.messageBox(title, msg, btns);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -238,6 +238,8 @@
|
|||||||
"edit": {
|
"edit": {
|
||||||
"delete_user_title": "Delete user",
|
"delete_user_title": "Delete user",
|
||||||
"delete_user_message": "Do you really want to delete this user? All associated documents, files and tags will be deleted",
|
"delete_user_message": "Do you really want to delete this user? All associated documents, files and tags will be deleted",
|
||||||
|
"edit_user_failed_title": "User already exists",
|
||||||
|
"edit_user_failed_message": "This username is already taken by another user",
|
||||||
"edit_user_title": "<small>Edit</small> \"{{ username }}\"",
|
"edit_user_title": "<small>Edit</small> \"{{ username }}\"",
|
||||||
"add_user_title": "<small>Add a</small> user",
|
"add_user_title": "<small>Add a</small> user",
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
@ -276,6 +278,8 @@
|
|||||||
"edit": {
|
"edit": {
|
||||||
"delete_group_title": "Delete group",
|
"delete_group_title": "Delete group",
|
||||||
"delete_group_message": "Do you really want to delete this group?",
|
"delete_group_message": "Do you really want to delete this group?",
|
||||||
|
"edit_group_failed_title": "Group already exists",
|
||||||
|
"edit_group_failed_message": "This group name is already taken by another group",
|
||||||
"edit_group_title": "Edit <small>\"{{ name }}\"</small>",
|
"edit_group_title": "Edit <small>\"{{ name }}\"</small>",
|
||||||
"add_group_title": "<small>Add a</small> group",
|
"add_group_title": "<small>Add a</small> group",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
|
@ -125,7 +125,7 @@ public class TestUserResource extends BaseJerseyTest {
|
|||||||
response = target().path("/user").request()
|
response = target().path("/user").request()
|
||||||
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, adminToken)
|
.cookie(TokenBasedSecurityFilter.COOKIE_NAME, adminToken)
|
||||||
.put(Entity.form(form));
|
.put(Entity.form(form));
|
||||||
Assert.assertNotSame(Status.OK, Status.fromStatusCode(response.getStatus()));
|
Assert.assertEquals(Status.BAD_REQUEST, Status.fromStatusCode(response.getStatus()));
|
||||||
json = response.readEntity(JsonObject.class);
|
json = response.readEntity(JsonObject.class);
|
||||||
Assert.assertEquals("AlreadyExistingUsername", json.getString("type"));
|
Assert.assertEquals("AlreadyExistingUsername", json.getString("type"));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user