Merge pull request #1230 from dbeaver/hotfix/CB-2785

CB-2785 delete user fix
This commit is contained in:
Alexander Skoblikov
2022-10-21 21:36:25 +03:00
committed by GitHub
@@ -158,6 +158,7 @@ public class CBEmbeddedSecurityController implements SMAdminController, SMAuthen
@Override
public void deleteUser(String userId) throws DBCException {
invalidateAllUserTokens(userId);
try (Connection dbCon = database.openConnection()) {
try (JDBCTransaction txn = new JDBCTransaction(dbCon)) {
deleteAuthSubject(dbCon, userId);
@@ -1221,6 +1222,14 @@ public class CBEmbeddedSecurityController implements SMAdminController, SMAuthen
}
}
private void invalidateAllUserTokens(String userId) throws DBCException {
try (Connection dbCon = database.openConnection()) {
JDBCUtils.executeStatement(dbCon, "DELETE FROM CB_AUTH_TOKEN WHERE USER_ID=?", userId);
} catch (SQLException e) {
throw new DBCException("Session invalidation failed", e);
}
}
private SMCredentials getCurrentUserCreds() throws SMException {
var currentUserCreds = credentialsProvider.getActiveUserCredentials();
if (currentUserCreds == null) {