KEYCLOAK-958 Support role names with '/' and '\'

This commit is contained in:
Stian Thorgersen 2015-01-15 12:21:58 +01:00
parent 82a7471042
commit 7ccea2bd10
7 changed files with 20 additions and 18 deletions

View file

@ -332,10 +332,11 @@ module.controller('ApplicationRoleDetailCtrl', function($scope, realm, applicati
$scope.changed = false;
role = angular.copy($scope.role);
var l = headers().location;
var id = l.substring(l.lastIndexOf("/") + 1);
$location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles/" + id);
Notifications.success("The role has been created.");
ApplicationRole.get({ realm: realm.realm, application : application.id, role: role.name }, function(role) {
var id = role.id;
$location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles/" + id);
Notifications.success("The role has been created.");
});
});
} else {
$scope.update();
@ -347,7 +348,7 @@ module.controller('ApplicationRoleDetailCtrl', function($scope, realm, applicati
$scope.role.$remove({
realm : realm.realm,
application : application.id,
role : $scope.role.name
role : $scope.role.id
}, function() {
$location.url("/realms/" + realm.realm + "/applications/" + application.id + "/roles");
Notifications.success("The role has been deleted.");

View file

@ -952,10 +952,11 @@ module.controller('RoleDetailCtrl', function($scope, realm, role, roles, applica
$scope.changed = false;
role = angular.copy($scope.role);
var l = headers().location;
var id = l.substring(l.lastIndexOf("/") + 1);
$location.url("/realms/" + realm.realm + "/roles/" + id);
Notifications.success("The role has been created.");
Role.get({ realm: realm.realm, role: role.name }, function(role) {
var id = role.id;
$location.url("/realms/" + realm.realm + "/roles/" + id);
Notifications.success("The role has been created.");
});
});
} else {
$scope.update();
@ -966,7 +967,7 @@ module.controller('RoleDetailCtrl', function($scope, realm, role, roles, applica
Dialog.confirmDelete($scope.role.name, 'role', function () {
$scope.role.$remove({
realm: realm.realm,
role: $scope.role.name
role: $scope.role.id
}, function () {
$location.url("/realms/" + realm.realm + "/roles");
Notifications.success("The role has been deleted.");

View file

@ -137,8 +137,8 @@ module.factory('UserFederatedIdentityLoader', function(Loader, UserFederatedIden
module.factory('RoleLoader', function(Loader, Role, $route, $q) {
return Loader.get(Role, function() {
module.factory('RoleLoader', function(Loader, RoleById, $route, $q) {
return Loader.get(RoleById, function() {
return {
realm : $route.current.params.realm,
role : $route.current.params.role
@ -154,8 +154,8 @@ module.factory('RoleListLoader', function(Loader, Role, $route, $q) {
});
});
module.factory('ApplicationRoleLoader', function(Loader, ApplicationRole, $route, $q) {
return Loader.get(ApplicationRole, function() {
module.factory('ApplicationRoleLoader', function(Loader, RoleById, $route, $q) {
return Loader.get(RoleById, function() {
return {
realm : $route.current.params.realm,
application : $route.current.params.application,

View file

@ -40,7 +40,7 @@
required> -->
</div>
</div>
<div class="form-group clearfix block">
<div class="form-group clearfix block" data-ng-hide="create">
<label class="col-sm-2 control-label" for="compositeSwitch" class="control-label">Composite Roles</label>
<div class="col-sm-4">
<input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch />

View file

@ -52,7 +52,7 @@
-->
<tbody>
<tr ng-repeat="role in roles">
<td><a href="#/realms/{{realm.realm}}/applications/{{application.id}}/roles/{{role.name}}">{{role.name}}</a></td>
<td><a href="#/realms/{{realm.realm}}/applications/{{application.id}}/roles/{{role.id}}">{{role.name}}</a></td>
<td>{{role.composite}}</td>
<td>{{role.description}}</td>
</tr>

View file

@ -29,7 +29,7 @@
<textarea class="form-control" rows="5" cols="50" id="description" name="description" data-ng-model="role.description"></textarea>
</div>
</div>
<div class="form-group">
<div class="form-group" data-ng-hide="create">
<label class="col-sm-2 control-label" for="compositeSwitch" class="control-label">Composite Roles</label>
<div class="col-sm-4">
<input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch />

View file

@ -46,7 +46,7 @@
-->
<tbody>
<tr ng-repeat="role in roles | filter:{name: searchQuery}">
<td><a href="#/realms/{{realm.realm}}/roles/{{role.name}}">{{role.name}}</a></td>
<td><a href="#/realms/{{realm.realm}}/roles/{{role.id}}">{{role.name}}</a></td>
<td>{{role.composite}}</td>
<td>{{role.description}}</td>
</tr>