Handle unshares with PUT

This commit is contained in:
NMerz 2020-11-15 10:38:43 -05:00
parent 7cb9639f9a
commit 7d827a4a7e
2 changed files with 7 additions and 3 deletions

View File

@ -43,13 +43,16 @@ public class ListGetter implements CallHandler{
int sharees = 0;
boolean verifiedAccess = false;
while ((sharees < 2 && accessResults.next()) || !verifiedAccess) {
int permissionLevel = accessResults.getInt("permissionLevel");
if (accessResults.getString("userID").equals(cognitoID)) {
verifiedAccess = true;
if (!ListPermissions.hasPermission(accessResults.getInt("permissionLevel"), "Read")) {
if (!ListPermissions.hasPermission(permissionLevel, "Read")) {
throw new AccessControlException("User " + cognitoID + " does not have permission to read list " + id);
}
}
sharees++;
if (permissionLevel > 0) {
sharees++;
}
}
boolean shared = false;
if (sharees > 1) {

View File

@ -22,7 +22,8 @@ public class ListSharer implements CallHandler {
}
final private String CHECK_ACCESS = "SELECT * from ListSharee WHERE listID = ? AND userID = ?;";
final private String SHARE_LIST = "INSERT INTO ListSharee(listID, userID, permissionLevel) VALUES(?, ?, ?) ON DUPLICATE KEY UPDATE permissionLevel = ?;";
final private String SHARE_LIST = "INSERT INTO ListSharee(listID, userID, permissionLevel, uiPosition) VALUES(?, ?, ?, ?) ON DUPLICATE KEY UPDATE permissionLevel = ?;";
public Object conductAction(Map<String, Object> bodyMap, HashMap<String, String> queryString, String cognitoID) throws SQLException {
PreparedStatement checkAccess = connection.prepareStatement(CHECK_ACCESS);