Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions api/src/__test__/core/utils/files/config-file-normalizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ test('it creates a MEMORY config with NO OPTIONAL values', () => {

test('it creates a FLASH config with OPTIONAL values', () => {
const basicConfig = cloneDeep(initialState);
// 2fa & t2fa should be ignored
basicConfig.remote['2Fa'] = 'yes';
basicConfig.local['2Fa'] = 'yes';
basicConfig.local.showT2Fa = 'yes';

basicConfig.api.extraOrigins = 'myextra.origins';
basicConfig.remote.upnpEnabled = 'yes';
basicConfig.connectionStatus.upnpStatus = 'Turned On';
Expand All @@ -93,15 +95,11 @@ test('it creates a FLASH config with OPTIONAL values', () => {
"extraOrigins": "myextra.origins",
"version": "",
},
"local": {
"2Fa": "yes",
"showT2Fa": "yes",
},
"local": {},
"notifier": {
"apikey": "",
},
"remote": {
"2Fa": "yes",
"accesstoken": "",
"apikey": "",
"avatar": "",
Expand All @@ -125,6 +123,7 @@ test('it creates a FLASH config with OPTIONAL values', () => {

test('it creates a MEMORY config with OPTIONAL values', () => {
const basicConfig = cloneDeep(initialState);
// 2fa & t2fa should be ignored
basicConfig.remote['2Fa'] = 'yes';
basicConfig.local['2Fa'] = 'yes';
basicConfig.local.showT2Fa = 'yes';
Expand All @@ -142,15 +141,11 @@ test('it creates a MEMORY config with OPTIONAL values', () => {
"minigraph": "PRE_INIT",
"upnpStatus": "Turned On",
},
"local": {
"2Fa": "yes",
"showT2Fa": "yes",
},
"local": {},
"notifier": {
"apikey": "",
},
"remote": {
"2Fa": "yes",
"accesstoken": "",
"allowedOrigins": "/var/run/unraid-notifications.sock, /var/run/unraid-php.sock, /var/run/unraid-cli.sock, https://connect.myunraid.net, https://connect-staging.myunraid.net, https://dev-my.myunraid.net:4000",
"apikey": "",
Expand Down
18 changes: 3 additions & 15 deletions api/src/__test__/store/modules/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,12 @@ test('Before init returns default values for all fields', async () => {
"minigraph": "PRE_INIT",
"upnpStatus": "",
},
"local": {
"2Fa": "",
"showT2Fa": "",
},
"local": {},
"nodeEnv": "test",
"notifier": {
"apikey": "",
},
"remote": {
"2Fa": "",
"accesstoken": "",
"allowedOrigins": "",
"apikey": "",
Expand Down Expand Up @@ -65,16 +61,12 @@ test('After init returns values from cfg file for all fields', async () => {
minigraph: 'PRE_INIT',
upnpStatus: '',
},
local: {
'2Fa': '',
showT2Fa: '',
},
local: {},
nodeEnv: 'test',
notifier: {
apikey: 'unnotify_30994bfaccf839c65bae75f7fa12dd5ee16e69389f754c3b98ed7d5',
},
remote: {
'2Fa': '',
accesstoken: '',
allowedOrigins: '',
apikey: '_______________________BIG_API_KEY_HERE_________________________',
Expand Down Expand Up @@ -122,16 +114,12 @@ test('updateUserConfig merges in changes to current state', async () => {
minigraph: 'PRE_INIT',
upnpStatus: '',
},
local: {
'2Fa': '',
showT2Fa: '',
},
local: {},
nodeEnv: 'test',
notifier: {
apikey: 'unnotify_30994bfaccf839c65bae75f7fa12dd5ee16e69389f754c3b98ed7d5',
},
remote: {
'2Fa': '',
accesstoken: '',
allowedOrigins: '',
apikey: '_______________________BIG_API_KEY_HERE_________________________',
Expand Down
6 changes: 1 addition & 5 deletions api/src/core/utils/files/config-file-normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ export const getWriteableConfig = <T extends ConfigType>(
version: api?.version ?? initialState.api.version,
extraOrigins: api?.extraOrigins ?? initialState.api.extraOrigins,
},
local: {
...(local?.['2Fa'] === 'yes' ? { '2Fa': local['2Fa'] } : {}),
...(local?.showT2Fa === 'yes' ? { showT2Fa: local.showT2Fa } : {}),
},
local: {},
notifier: {
apikey: notifier.apikey ?? initialState.notifier.apikey,
},
remote: {
...(remote?.['2Fa'] === 'yes' ? { '2Fa': remote['2Fa'] } : {}),
wanaccess: remote.wanaccess ?? initialState.remote.wanaccess,
wanport: remote.wanport ?? initialState.remote.wanport,
...(remote.upnpEnabled ? { upnpEnabled: remote.upnpEnabled } : {}),
Expand Down
6 changes: 1 addition & 5 deletions api/src/store/modules/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const initialState: SliceState = {
status: FileLoadStatus.UNLOADED,
nodeEnv: NODE_ENV,
remote: {
'2Fa': '',
wanaccess: '',
wanport: '',
upnpEnabled: '',
Expand All @@ -51,10 +50,7 @@ export const initialState: SliceState = {
allowedOrigins: '',
dynamicRemoteAccessType: DynamicRemoteAccessType.DISABLED,
},
local: {
showT2Fa: '',
'2Fa': '',
},
local: {},
api: {
extraOrigins: '',
version: '',
Expand Down
11 changes: 1 addition & 10 deletions api/src/types/my-servers-config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ interface MyServersConfig extends Record<string, unknown> {
version: string;
extraOrigins: string;
};
local: {
'2Fa'?: string;
showT2Fa?: string;
};
local: {};
notifier: {
apikey: string;
};
remote: {
'2Fa'?: string;
wanaccess: string;
wanport: string;
upnpEnabled?: string;
Expand All @@ -38,12 +34,7 @@ export interface MyServersConfigWithMandatoryHiddenFields extends MyServersConfi
api: {
extraOrigins: string;
};
local: MyServersConfig['local'] & {
'2Fa': string;
showT2Fa: string;
};
remote: MyServersConfig['remote'] & {
'2Fa': string;
upnpEnabled: string;
dynamicRemoteAccessType: DynamicRemoteAccessType;
};
Expand Down
8 changes: 2 additions & 6 deletions plugin/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
# Hidden Flags

Use the following flags for additional functionality
1. Setting showT2Fa to "yes" will give you early access to unreleased features, specifically T2FA and the ability to specify extra origins.
```
[local]
showT2Fa="yes"
```
2. The deleteOnUninstall setting is for internal developers who are switching between the staging and production plugins, or otherwise installing/uninstalling the plugin a lot. Setting this to "no" prevents the uninstall routine from deleting your local flash backup files and disabling Remote Access. The assumption is that you will be reinstalling the plugin and don't want to lose those settings.

1. The deleteOnUninstall setting is for internal developers who are switching between the staging and production plugins, or otherwise installing/uninstalling the plugin a lot. Setting this to "no" prevents the uninstall routine from deleting your local flash backup files and disabling Remote Access. The assumption is that you will be reinstalling the plugin and don't want to lose those settings.
```
[plugin]
deleteOnUninstall="no"
Expand Down
Loading