mirror of
https://github.com/unraid/api.git
synced 2026-05-06 23:20:30 -05:00
fix: non user accounts throwing null for id/description and disable silly logging by default
This commit is contained in:
@@ -91,7 +91,6 @@ export class ApiManager extends EventEmitter {
|
||||
this.replace('upc', apiKey, {
|
||||
// @todo: fix UPC being root
|
||||
userId: '0'
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -10,6 +10,11 @@
|
||||
*/
|
||||
const isProduction = process.env.NODE_ENV === 'production';
|
||||
|
||||
/**
|
||||
* If we're in silly logging mode.
|
||||
*/
|
||||
const isSilly = Boolean(process.env.SILLY);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
const noop = () => {};
|
||||
|
||||
@@ -32,7 +37,7 @@ export const logger = {
|
||||
levels: ['error', 'warn', 'info', 'debug', 'trace', 'silly'],
|
||||
info: isProduction ? noop : console.info,
|
||||
log: isProduction ? noop : console.info,
|
||||
silly: isProduction ? noop : console.debug,
|
||||
silly: isProduction ? noop : (isSilly ? console.debug : noop),
|
||||
timer: isProduction ? noop : console.debug,
|
||||
trace: isProduction ? noop : console.debug,
|
||||
transport: 'console',
|
||||
|
||||
@@ -306,9 +306,11 @@ const apiKeyToUser = async (apiKey: string) => {
|
||||
try {
|
||||
const keyName = apiManager.getNameFromKey(apiKey);
|
||||
|
||||
log.silly('Found key "%s".', keyName);
|
||||
|
||||
// Force upc into it's own group that's not a user group
|
||||
if (keyName && keyName === 'upc') {
|
||||
return { name: 'upc', role: 'upc' };
|
||||
return { id: -1, description: 'UPC service account', name: 'upc', role: 'upc' };
|
||||
}
|
||||
|
||||
if (keyName) {
|
||||
@@ -324,7 +326,7 @@ const apiKeyToUser = async (apiKey: string) => {
|
||||
log.debug('Failed looking up API key with "%s"', (error as Error).message);
|
||||
}
|
||||
|
||||
return { name: 'guest', role: 'guest' };
|
||||
return { id: -1, description: 'A guest user', name: 'guest', role: 'guest' };
|
||||
};
|
||||
|
||||
// Update array values when slots change
|
||||
|
||||
Reference in New Issue
Block a user