(usernames, accountManager, config, host)
| 65 | } |
| 66 | |
| 67 | async function deleteUsers (usernames, accountManager, config, host) { |
| 68 | const oidcManager = fromServerConfig({ ...config, host }) |
| 69 | const deletingUsers = usernames.map(async username => { |
| 70 | try { |
| 71 | const user = accountManager.userAccountFrom({ username }) |
| 72 | await oidcManager.users.deleteUser(user) |
| 73 | } catch (error) { |
| 74 | if (error.message !== 'No email given') { |
| 75 | throw error |
| 76 | } |
| 77 | } |
| 78 | const userDirectory = accountManager.accountDirFor(username) |
| 79 | await fs.remove(userDirectory) |
| 80 | }) |
| 81 | await Promise.all(deletingUsers) |
| 82 | console.info(`Deleted ${deletingUsers.length} users succeeded`) |
| 83 | } |
| 84 | |
| 85 | function getInvalidUsernames (config) { |
| 86 | const usernames = loadUsernames(config) |
no test coverage detected