'Fix' org creation on fakeuser setup

This commit is contained in:
KennyTV 2020-09-03 20:45:53 +02:00
parent dbc536b7e5
commit bea83c9b1f
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
2 changed files with 5 additions and 4 deletions

View File

@ -7,6 +7,7 @@ import io.papermc.hangar.db.dao.HangarDao;
import io.papermc.hangar.db.dao.OrganizationDao;
import io.papermc.hangar.db.dao.UserDao;
import io.papermc.hangar.db.model.OrganizationsTable;
import io.papermc.hangar.db.model.UsersTable;
import io.papermc.hangar.model.NotificationType;
import io.papermc.hangar.model.Role;
import io.papermc.hangar.model.viewhelpers.UserData;
@ -21,6 +22,7 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -69,7 +71,9 @@ public class OrgFactory {
}
} else {
authOrgUser = new AuthUser(-100, name, dummyEmail, "", Locale.ENGLISH, null);
userDao.get().insert(new UsersTable(authOrgUser.getId(), null, name, dummyEmail, null, List.of(), false, authOrgUser.getLang().toLanguageTag()));
}
// Just a note, the /api/sync_sso creates the org user here, so it will already be created when the above response is returned
OrganizationsTable org = new OrganizationsTable(name, ownerId, authOrgUser.getId());
org = organizationDao.get().insert(org);

View File

@ -66,10 +66,7 @@ public class RoleService {
}
public void addRole(ProjectsTable projectsTable, long userId, Role role, boolean isAccepted) {
boolean exists = userProjectRolesDao.get().getByProjectAndUser(projectsTable.getId(), userId) != null;
System.out.println(exists);
if (!exists) {
System.out.println("add member");
if (userProjectRolesDao.get().getByProjectAndUser(projectsTable.getId(), userId) == null) {
addMember(projectsTable.getId(), userId);
}
userProjectRolesDao.get().insert(new UserProjectRolesTable(userId, role.getValue(), projectsTable.getId(), isAccepted));