Skip to content

Commit 0a01a15

Browse files
authored
feat: adds deleteAllRolesForUser functions (#46)
1 parent 6622ffb commit 0a01a15

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/main/java/io/supertokens/storage/postgresql/Start.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,8 +1534,11 @@ public boolean doesRoleExist(String role) throws StorageQueryException {
15341534

15351535
@Override
15361536
public int deleteAllRolesForUser(String userId) throws StorageQueryException {
1537-
// TODO
1538-
return 0;
1537+
try {
1538+
return UserRolesQueries.deleteAllRolesForUser(this, userId);
1539+
} catch (SQLException e) {
1540+
throw new StorageQueryException(e);
1541+
}
15391542
}
15401543

15411544
@Override

src/main/java/io/supertokens/storage/postgresql/queries/UserRolesQueries.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,9 @@ public static String[] getRolesThatHavePermission(Start start, String permission
226226
});
227227
}
228228

229+
public static int deleteAllRolesForUser(Start start, String userId) throws SQLException, StorageQueryException {
230+
String QUERY = "DELETE FROM " + getConfig(start).getUserRolesTable() + " WHERE user_id = ?";
231+
return update(start, QUERY, pst -> pst.setString(1, userId));
232+
}
233+
229234
}

0 commit comments

Comments
 (0)