feat: remove sso user options

This commit is contained in:
Eli Bosley
2025-01-23 13:16:06 -05:00
parent f30292484d
commit 75d7e08824
3 changed files with 14 additions and 7 deletions

View File

@@ -214,7 +214,7 @@ export const config = createSlice({
if (state.remote.ssoSubIds.includes(action.payload)) {
return;
}
const stateAsArray = state.remote.ssoSubIds.split(',');
const stateAsArray = state.remote.ssoSubIds.split(',').filter((id) => id !== '');
stateAsArray.push(action.payload);
state.remote.ssoSubIds = stateAsArray.join(',');
},

View File

@@ -4,6 +4,7 @@ import { CommandRunner, InquirerService, Option, OptionChoiceFor, SubCommand } f
import { store } from '@app/store/index';
import { loadConfigFile, removeSsoUser } from '@app/store/modules/config';
import { writeConfigSync } from '@app/store/sync/config-disk-sync';
import { LogService } from '@app/unraid-api/cli/log.service';
import { RemoveSSOUserQuestionSet } from '@app/unraid-api/cli/sso/remove-sso-user.questions';
@@ -26,9 +27,13 @@ export class RemoveSSOUserCommand extends CommandRunner {
}
public async run(_input: string[], options: RemoveSSOUserCommandOptions): Promise<void> {
await store.dispatch(loadConfigFile());
console.log('options', options);
options = await this.inquirerService.prompt(RemoveSSOUserQuestionSet.name, options);
store.dispatch(removeSsoUser(options.username === 'all' ? null : options.username));
this.logger.info('User/s removed ' + options.username);
if (options.username === 'all') {
this.logger.info('All users removed from SSO');
} else {
this.logger.info('User removed: ' + options.username);
}
writeConfigSync('flash');
}
}

View File

@@ -1,11 +1,11 @@
import { ChoicesFor, Question, QuestionSet, } from 'nest-commander';
import { store } from '@app/store/index';
import { loadConfigFile } from '@app/store/modules/config';
import { LogService } from '@app/unraid-api/cli/log.service';
@QuestionSet({ name: 'remove-user' })
export class RemoveSSOUserQuestionSet {
constructor(private readonly logger: LogService) {}
static name = 'remove-user';
@Question({
@@ -19,9 +19,11 @@ export class RemoveSSOUserQuestionSet {
@ChoicesFor({ name: 'username' })
async choicesForUsername() {
await store.dispatch(loadConfigFile());
const users = store.getState().config.remote.ssoSubIds.split(',').filter((user) => user !== '');
if (users.length === 0) {
this.logger.error('No SSO Users Found');
process.exit(0);
}
users.push('all');
return users;
}