11import { F_OK } from 'constants' ;
2- import { randomBytes } from 'crypto' ;
32import { writeFileSync } from 'fs' ;
43import { access } from 'fs/promises' ;
54
@@ -24,7 +23,6 @@ import { setupRemoteAccessThunk } from '@app/store/actions/setup-remote-access';
2423import { FileLoadStatus } from '@app/store/types' ;
2524import { type RecursivePartial } from '@app/types' ;
2625import { type MyServersConfig , type MyServersConfigMemory } from '@app/types/my-servers-config' ;
27- import { isFulfilled } from '@app/utils' ;
2826
2927export type SliceState = {
3028 status : FileLoadStatus ;
@@ -219,7 +217,18 @@ export const config = createSlice({
219217 const stateAsArray = state . remote . ssoSubIds . split ( ',' ) ;
220218 stateAsArray . push ( action . payload ) ;
221219 state . remote . ssoSubIds = stateAsArray . join ( ',' ) ;
222- }
220+ } ,
221+ removeSsoUser ( state , action : PayloadAction < string | null > ) {
222+ if ( action . payload === null ) {
223+ state . remote . ssoSubIds = '' ;
224+ return ;
225+ }
226+ if ( ! state . remote . ssoSubIds . includes ( action . payload ) ) {
227+ return ;
228+ }
229+ const stateAsArray = state . remote . ssoSubIds . split ( ',' ) . filter ( ( id ) => id !== action . payload ) ;
230+ state . remote . ssoSubIds = stateAsArray . join ( ',' ) ;
231+ } ,
223232 } ,
224233 extraReducers ( builder ) {
225234 builder . addCase ( loadConfigFile . pending , ( state ) => {
@@ -300,12 +309,14 @@ export const {
300309 setUpnpState,
301310 setWanPortToValue,
302311 setWanAccess,
312+ removeSsoUser,
303313} = actions ;
304314
305315/**
306316 * Actions that should trigger a flash write
307317 */
308318export const configUpdateActionsFlash = isAnyOf (
319+ addSsoUser ,
309320 updateUserConfig ,
310321 updateAccessTokens ,
311322 updateAllowedOrigins ,
@@ -314,7 +325,8 @@ export const configUpdateActionsFlash = isAnyOf(
314325 setWanAccess ,
315326 setupRemoteAccessThunk . fulfilled ,
316327 logoutUser . fulfilled ,
317- loginUser . fulfilled
328+ loginUser . fulfilled ,
329+ removeSsoUser
318330) ;
319331
320332/**
0 commit comments