mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
feat: remove sso user options
This commit is contained in:
@@ -214,7 +214,7 @@ export const config = createSlice({
|
|||||||
if (state.remote.ssoSubIds.includes(action.payload)) {
|
if (state.remote.ssoSubIds.includes(action.payload)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const stateAsArray = state.remote.ssoSubIds.split(',');
|
const stateAsArray = state.remote.ssoSubIds.split(',').filter((id) => id !== '');
|
||||||
stateAsArray.push(action.payload);
|
stateAsArray.push(action.payload);
|
||||||
state.remote.ssoSubIds = stateAsArray.join(',');
|
state.remote.ssoSubIds = stateAsArray.join(',');
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { CommandRunner, InquirerService, Option, OptionChoiceFor, SubCommand } f
|
|||||||
|
|
||||||
import { store } from '@app/store/index';
|
import { store } from '@app/store/index';
|
||||||
import { loadConfigFile, removeSsoUser } from '@app/store/modules/config';
|
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 { LogService } from '@app/unraid-api/cli/log.service';
|
||||||
import { RemoveSSOUserQuestionSet } from '@app/unraid-api/cli/sso/remove-sso-user.questions';
|
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> {
|
public async run(_input: string[], options: RemoveSSOUserCommandOptions): Promise<void> {
|
||||||
await store.dispatch(loadConfigFile());
|
await store.dispatch(loadConfigFile());
|
||||||
console.log('options', options);
|
|
||||||
options = await this.inquirerService.prompt(RemoveSSOUserQuestionSet.name, options);
|
options = await this.inquirerService.prompt(RemoveSSOUserQuestionSet.name, options);
|
||||||
store.dispatch(removeSsoUser(options.username === 'all' ? null : options.username));
|
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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { ChoicesFor, Question, QuestionSet, } from 'nest-commander';
|
import { ChoicesFor, Question, QuestionSet, } from 'nest-commander';
|
||||||
|
|
||||||
import { store } from '@app/store/index';
|
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' })
|
@QuestionSet({ name: 'remove-user' })
|
||||||
export class RemoveSSOUserQuestionSet {
|
export class RemoveSSOUserQuestionSet {
|
||||||
|
constructor(private readonly logger: LogService) {}
|
||||||
static name = 'remove-user';
|
static name = 'remove-user';
|
||||||
|
|
||||||
@Question({
|
@Question({
|
||||||
@@ -19,9 +19,11 @@ export class RemoveSSOUserQuestionSet {
|
|||||||
|
|
||||||
@ChoicesFor({ name: 'username' })
|
@ChoicesFor({ name: 'username' })
|
||||||
async choicesForUsername() {
|
async choicesForUsername() {
|
||||||
await store.dispatch(loadConfigFile());
|
|
||||||
const users = store.getState().config.remote.ssoSubIds.split(',').filter((user) => user !== '');
|
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');
|
users.push('all');
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user