add dynamic role assignment

pull/4/head
Felix Prahl-Kamps 2019-08-22 18:25:34 +02:00
parent b8f850f163
commit 8f2de6787d
2 changed files with 15 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import lu.circl.mispbump.auxiliary.PreferenceManager;
import lu.circl.mispbump.customViews.ProgressActionView; import lu.circl.mispbump.customViews.ProgressActionView;
import lu.circl.mispbump.models.SyncInformation; import lu.circl.mispbump.models.SyncInformation;
import lu.circl.mispbump.models.restModels.Organisation; import lu.circl.mispbump.models.restModels.Organisation;
import lu.circl.mispbump.models.restModels.Role;
import lu.circl.mispbump.models.restModels.Server; import lu.circl.mispbump.models.restModels.Server;
import lu.circl.mispbump.models.restModels.User; import lu.circl.mispbump.models.restModels.User;
@ -156,9 +157,15 @@ public class UploadActivity extends AppCompatActivity {
User syncUser = syncInformation.getRemote().getSyncUser(); User syncUser = syncInformation.getRemote().getSyncUser();
syncUser.setOrgId(organisation.getId()); syncUser.setOrgId(organisation.getId());
syncUser.setRoleId(6);
syncUser.setTermsAccepted(true); syncUser.setTermsAccepted(true);
Role[] roles = preferenceManager.getRoles();
for (Role role : roles) {
if (role.isSyncUserRole()) {
syncUser.setRoleId(role.getId());
}
}
return syncUser; return syncUser;
} }

View File

@ -64,6 +64,13 @@ public class Role {
@SerializedName("permission_description") @SerializedName("permission_description")
private String permissionDescription; private String permissionDescription;
public boolean isSyncUserRole() {
return permSync && permAuth && permTagger && permTagEditor && permSharingGroup
&& permDelegate && permSighting && permPublishZmq && permPublishKafka;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }