fix: bail on undefined in checkKey function

This commit is contained in:
Alexis
2021-09-15 13:19:10 +09:30
parent e5de6de30d
commit 2e15e98eb1
2 changed files with 8 additions and 5 deletions
+7 -3
View File
@@ -330,14 +330,18 @@ export class ApiManager extends EventEmitter {
await lock.runExclusive(async () => {
apiManagerLogger.debug('Checking API key for validity.');
const file = loadState<{ remote: { apikey: string } }>(filePath);
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/non-nullable-type-assertion-style
const apiKey = dotProp.get(file, 'remote.apikey')! as string;
const apiKey: string | undefined = dotProp.get(file, 'remote.apikey');
// No API key passed
if (apiKey === undefined) {
return;
}
log.debug('Checking API key "%s".', apiKey);
// Same key as current
if (!force && (apiKey === this.getKey('my_servers')?.key)) {
apiManagerLogger.debug('%s was updated but the API key didn\'t change', filePath);
apiManagerLogger.debug('%s was updated but the API key didn\'t change.', filePath);
return;
}
+1 -2
View File
@@ -38,7 +38,7 @@ export const myservers = () => {
// If we have one enable/disable it. If this is
// missing it's likely we shipped without Sentry
// initialised. This would be done for a reason!
// initialized. This would be done for a reason!
if (sentryClient) {
// Check if the value changed
if (sentryClient.getOptions().enabled !== isEnabled) {
@@ -49,7 +49,6 @@ export const myservers = () => {
}
}
// @todo: add cfg files similar to states
// Update myservers config, this is used for origin checks in graphql
myServersConfig.remote.wanaccess = file.remote.wanaccess;
myServersConfig.remote.wanport = file.remote.wanport;