removes admin flag from user object

This commit is contained in:
Sebastian Sdorra
2019-03-13 12:07:18 +01:00
parent 9d0e3e568a
commit a2f83e2429
12 changed files with 193 additions and 267 deletions

View File

@@ -157,12 +157,6 @@ public class User extends BasicPropertiesAware implements Principal, ModelObject
{ {
boolean result = false; boolean result = false;
if (user.isAdmin() != admin)
{
result = true;
user.setAdmin(admin);
}
if (user.isActive() != active) if (user.isActive() != active)
{ {
result = true; result = true;
@@ -229,7 +223,6 @@ public class User extends BasicPropertiesAware implements Principal, ModelObject
&& Objects.equal(displayName, other.displayName) && Objects.equal(displayName, other.displayName)
&& Objects.equal(mail, other.mail) && Objects.equal(mail, other.mail)
&& Objects.equal(type, other.type) && Objects.equal(type, other.type)
&& Objects.equal(admin, other.admin)
&& Objects.equal(active, other.active) && Objects.equal(active, other.active)
&& Objects.equal(password, other.password) && Objects.equal(password, other.password)
&& Objects.equal(creationDate, other.creationDate) && Objects.equal(creationDate, other.creationDate)
@@ -246,7 +239,7 @@ public class User extends BasicPropertiesAware implements Principal, ModelObject
@Override @Override
public int hashCode() public int hashCode()
{ {
return Objects.hashCode(name, displayName, mail, type, admin, password, return Objects.hashCode(name, displayName, mail, type, password,
active, creationDate, lastModified, properties); active, creationDate, lastModified, properties);
} }
@@ -269,7 +262,6 @@ public class User extends BasicPropertiesAware implements Principal, ModelObject
.add("displayName",displayName) .add("displayName",displayName)
.add("mail", mail) .add("mail", mail)
.add("password", pwd) .add("password", pwd)
.add("admin", admin)
.add("type", type) .add("type", type)
.add("active", active) .add("active", active)
.add("creationDate", creationDate) .add("creationDate", creationDate)
@@ -385,17 +377,6 @@ public class User extends BasicPropertiesAware implements Principal, ModelObject
return active; return active;
} }
/**
* Method description
*
*
* @return
*/
public boolean isAdmin()
{
return admin;
}
/** /**
* Method description * Method description
* *
@@ -424,17 +405,6 @@ public class User extends BasicPropertiesAware implements Principal, ModelObject
this.active = active; this.active = active;
} }
/**
* Method description
*
*
* @param admin
*/
public void setAdmin(boolean admin)
{
this.admin = admin;
}
/** /**
* Method description * Method description
* *
@@ -518,9 +488,6 @@ public class User extends BasicPropertiesAware implements Principal, ModelObject
/** Field description */ /** Field description */
private boolean active = true; private boolean active = true;
/** Field description */
private boolean admin = false;
/** Field description */ /** Field description */
private Long creationDate; private Long creationDate;

View File

@@ -6,7 +6,6 @@ export type User = {
name: string, name: string,
mail: string, mail: string,
password: string, password: string,
admin: boolean,
active: boolean, active: boolean,
type?: string, type?: string,
creationDate?: string, creationDate?: string,

View File

@@ -37,7 +37,6 @@ class UserForm extends React.Component<Props, State> {
displayName: "", displayName: "",
mail: "", mail: "",
password: "", password: "",
admin: false,
active: true, active: true,
_links: {} _links: {}
}, },
@@ -167,12 +166,6 @@ class UserForm extends React.Component<Props, State> {
<div className="columns"> <div className="columns">
<div className="column"> <div className="column">
{passwordChangeField} {passwordChangeField}
<Checkbox
label={t("user.admin")}
onChange={this.handleAdminChange}
checked={user ? user.admin : false}
helpText={t("help.adminHelpText")}
/>
<Checkbox <Checkbox
label={t("user.active")} label={t("user.active")}
onChange={this.handleActiveChange} onChange={this.handleActiveChange}
@@ -225,10 +218,6 @@ class UserForm extends React.Component<Props, State> {
}); });
}; };
handleAdminChange = (admin: boolean) => {
this.setState({ user: { ...this.state.user, admin } });
};
handleActiveChange = (active: boolean) => { handleActiveChange = (active: boolean) => {
this.setState({ user: { ...this.state.user, active } }); this.setState({ user: { ...this.state.user, active } });
}; };

View File

@@ -29,12 +29,6 @@ class Details extends React.Component<Props> {
<MailLink address={user.mail} /> <MailLink address={user.mail} />
</td> </td>
</tr> </tr>
<tr>
<td className="has-text-weight-semibold">{t("user.admin")}</td>
<td>
<Checkbox checked={user.admin} />
</td>
</tr>
<tr> <tr>
<td className="has-text-weight-semibold">{t("user.active")}</td> <td className="has-text-weight-semibold">{t("user.active")}</td>
<td> <td>

View File

@@ -23,7 +23,7 @@ export default class UserRow extends React.Component<Props> {
<a href={`mailto: ${user.mail}`}>{user.mail}</a> <a href={`mailto: ${user.mail}`}>{user.mail}</a>
</td> </td>
<td className="is-hidden-mobile"> <td className="is-hidden-mobile">
<input type="checkbox" id="admin" checked={user.admin} readOnly /> <input type="checkbox" id="active" checked={user.active} readOnly />
</td> </td>
</tr> </tr>
); );

View File

@@ -21,7 +21,7 @@ class UserTable extends React.Component<Props> {
<th className="is-hidden-mobile">{t("user.name")}</th> <th className="is-hidden-mobile">{t("user.name")}</th>
<th>{t("user.displayName")}</th> <th>{t("user.displayName")}</th>
<th>{t("user.mail")}</th> <th>{t("user.mail")}</th>
<th className="is-hidden-mobile">{t("user.admin")}</th> <th className="is-hidden-mobile">{t("user.active")}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View File

@@ -121,7 +121,7 @@ public class AuthorizationChangedEventProducer {
} }
private boolean isAuthorizationDataModified(User user, User beforeModification) { private boolean isAuthorizationDataModified(User user, User beforeModification) {
return user.isAdmin() != beforeModification.isAdmin() || user.isActive() != beforeModification.isActive(); return user.isActive() != beforeModification.isActive();
} }
private void fireEventForUser(String username) { private void fireEventForUser(String username) {

View File

@@ -271,11 +271,6 @@ public class DefaultAuthorizationCollector implements AuthorizationCollector
} }
private boolean isAdmin(User user, GroupNames groups) { private boolean isAdmin(User user, GroupNames groups) {
boolean admin = user.isAdmin();
if (admin) {
logger.debug("user {} is marked as admin, because of the user flag", user.getName());
return true;
}
if (isUserAdminInConfiguration(user)) { if (isUserAdminInConfiguration(user)) {
logger.debug("user {} is marked as admin, because of the admin user configuration", user.getName()); logger.debug("user {} is marked as admin, because of the admin user configuration", user.getName());
return true; return true;

View File

@@ -142,7 +142,6 @@ public class GitLfsITCase {
dto.setDisplayName(user.getDisplayName()); dto.setDisplayName(user.getDisplayName());
dto.setType(user.getType()); dto.setType(user.getType());
dto.setActive(user.isActive()); dto.setActive(user.isActive());
dto.setAdmin(user.isAdmin());
dto.setPassword(user.getPassword()); dto.setPassword(user.getPassword());
createResource(adminClient, "users") createResource(adminClient, "users")
.accept("*/*") .accept("*/*")

View File

@@ -133,7 +133,6 @@ public class UserPermissionITCase extends AbstractPermissionITCaseBase<User>
"scm-admin@scm-manager.org"); "scm-admin@scm-manager.org");
user.setPassword("hallo123"); user.setPassword("hallo123");
user.setAdmin(true);
user.setType("xml"); user.setType("xml");
return user; return user;

View File

@@ -115,7 +115,7 @@ public class AuthorizationChangedEventProducerTest {
producer.onEvent(new UserModificationEvent(HandlerEventType.CREATE, userModified, user)); producer.onEvent(new UserModificationEvent(HandlerEventType.CREATE, userModified, user));
assertEventIsNotFired(); assertEventIsNotFired();
userModified.setAdmin(true); userModified.setActive(false);
producer.onEvent(new UserModificationEvent(HandlerEventType.BEFORE_CREATE, userModified, user)); producer.onEvent(new UserModificationEvent(HandlerEventType.BEFORE_CREATE, userModified, user));
assertEventIsNotFired(); assertEventIsNotFired();

View File

@@ -197,22 +197,6 @@ public class DefaultAuthorizationCollectorTest {
assertThat(authInfo.getObjectPermissions(), nullValue()); assertThat(authInfo.getObjectPermissions(), nullValue());
} }
/**
* Tests {@link AuthorizationCollector#collect()} as admin.
*/
@Test
@SubjectAware(
configuration = "classpath:sonia/scm/shiro-001.ini"
)
public void testCollectAsAdmin() {
User trillian = UserTestData.createTrillian();
trillian.setAdmin(true);
authenticate(trillian, "main");
AuthorizationInfo authInfo = collector.collect();
assertIsAdmin(authInfo);
}
/** /**
* Tests {@link AuthorizationCollector#collect()} with repository permissions. * Tests {@link AuthorizationCollector#collect()} with repository permissions.
*/ */