fix permissions not unique

This commit is contained in:
f43nd1r 2018-08-24 05:35:14 +02:00
parent 1b6a396ccd
commit 9a63860c68
3 changed files with 19 additions and 4 deletions

View file

@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.faendir.acra.model;
import org.springframework.data.annotation.PersistenceConstructor;
@ -21,6 +20,7 @@ import org.springframework.lang.NonNull;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@ -41,8 +41,12 @@ import java.util.stream.Stream;
public class User implements UserDetails {
@Id private String username;
@Enumerated(EnumType.STRING)
@ElementCollection(fetch = FetchType.EAGER) private Set<Role> roles;
@ElementCollection(fetch = FetchType.EAGER) private Set<Permission> permissions;
@Column(nullable = false)
@ElementCollection(fetch = FetchType.EAGER)
private Set<Role> roles;
@Column(nullable = false)
@ElementCollection(fetch = FetchType.EAGER)
private Set<Permission> permissions;
private String password;
@PersistenceConstructor

View file

@ -91,7 +91,10 @@ public class UserManagerView extends BaseView {
ComboBox<Permission.Level> levelComboBox = new ComboBox<>(null, Arrays.asList(Permission.Level.values()));
levelComboBox.setEmptySelectionAllowed(false);
levelComboBox.setValue(permission);
levelComboBox.addValueChangeListener(e -> userService.setPermission(user, app, e.getValue()));
levelComboBox.addValueChangeListener(e -> {
userService.setPermission(user, app, e.getValue());
userGrid.getDataProvider().refreshAll();
});
return levelComboBox;
}, new ComponentRenderer(), Messages.ACCESS_PERMISSION, app.getName());
}

View file

@ -616,4 +616,12 @@ databaseChangeLog:
type: INT
constraints:
nullable: false
- changeSet:
id: 2018-08-24-fix-permission-key
author: lukas
changes:
- addPrimaryKey:
columnNames: user_username, app_id
tableName: user_permissions
constraintName: PK_user_permissions