fixing sharing settings error
This commit is contained in:
parent
999ca21519
commit
4afff63415
2
Procfile
2
Procfile
@ -1 +1 @@
|
|||||||
web: node ./backend/index.js --Client-authenticationRequired=false
|
web: node ./backend/index.js --Client-authenticationRequired=false --Client-Sharing-enabled=false
|
||||||
|
|||||||
@ -136,6 +136,9 @@ export class AdminMWs {
|
|||||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||||
const original = Config.original();
|
const original = Config.original();
|
||||||
original.Client.authenticationRequired = <boolean>req.body.settings;
|
original.Client.authenticationRequired = <boolean>req.body.settings;
|
||||||
|
if (original.Client.authenticationRequired === false) {
|
||||||
|
original.Client.Sharing.enabled = false;
|
||||||
|
}
|
||||||
original.save();
|
original.save();
|
||||||
await ConfigDiagnostics.runDiagnostics();
|
await ConfigDiagnostics.runDiagnostics();
|
||||||
Logger.info(LOG_TAG, 'new config:');
|
Logger.info(LOG_TAG, 'new config:');
|
||||||
|
|||||||
@ -104,6 +104,10 @@ export class ConfigDiagnostics {
|
|||||||
config.Server.database.type === DatabaseType.memory) {
|
config.Server.database.type === DatabaseType.memory) {
|
||||||
throw new Error('Memory Database do not support sharing');
|
throw new Error('Memory Database do not support sharing');
|
||||||
}
|
}
|
||||||
|
if (sharing.enabled === true &&
|
||||||
|
config.Client.authenticationRequired === false) {
|
||||||
|
throw new Error('In case of no authentication, sharing is not supported');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async testMapConfig(map: ClientConfig.MapConfig) {
|
static async testMapConfig(map: ClientConfig.MapConfig) {
|
||||||
@ -118,10 +122,11 @@ export class ConfigDiagnostics {
|
|||||||
if (Config.Server.database.type !== DatabaseType.memory) {
|
if (Config.Server.database.type !== DatabaseType.memory) {
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testDatabase(Config.Server.database);
|
await ConfigDiagnostics.testDatabase(Config.Server.database);
|
||||||
} catch (err) {
|
} catch (ex) {
|
||||||
Logger.warn(LOG_TAG, '[SQL error]', err);
|
const err: Error = ex;
|
||||||
|
Logger.warn(LOG_TAG, '[SQL error]', err.toString());
|
||||||
Logger.warn(LOG_TAG, 'Error during initializing SQL falling back temporally to memory DB');
|
Logger.warn(LOG_TAG, 'Error during initializing SQL falling back temporally to memory DB');
|
||||||
NotificationManager.warning('Error during initializing SQL falling back temporally to memory DB', err);
|
NotificationManager.warning('Error during initializing SQL falling back temporally to memory DB', err.toString());
|
||||||
Config.setDatabaseType(DatabaseType.memory);
|
Config.setDatabaseType(DatabaseType.memory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,11 +134,12 @@ export class ConfigDiagnostics {
|
|||||||
if (Config.Server.thumbnail.processingLibrary !== ThumbnailProcessingLib.Jimp) {
|
if (Config.Server.thumbnail.processingLibrary !== ThumbnailProcessingLib.Jimp) {
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testThumbnailLib(Config.Server.thumbnail.processingLibrary);
|
await ConfigDiagnostics.testThumbnailLib(Config.Server.thumbnail.processingLibrary);
|
||||||
} catch (err) {
|
} catch (ex) {
|
||||||
|
const err: Error = ex;
|
||||||
NotificationManager.warning('Thumbnail hardware acceleration is not possible.' +
|
NotificationManager.warning('Thumbnail hardware acceleration is not possible.' +
|
||||||
' \'' + ThumbnailProcessingLib[Config.Server.thumbnail.processingLibrary] + '\' node module is not found.' +
|
' \'' + ThumbnailProcessingLib[Config.Server.thumbnail.processingLibrary] + '\' node module is not found.' +
|
||||||
' Falling back temporally to JS based thumbnail generation', err);
|
' Falling back temporally to JS based thumbnail generation', err.toString());
|
||||||
Logger.warn(LOG_TAG, '[Thumbnail hardware acceleration] module error: ', err);
|
Logger.warn(LOG_TAG, '[Thumbnail hardware acceleration] module error: ', err.toString());
|
||||||
Logger.warn(LOG_TAG, 'Thumbnail hardware acceleration is not possible.' +
|
Logger.warn(LOG_TAG, 'Thumbnail hardware acceleration is not possible.' +
|
||||||
' \'' + ThumbnailProcessingLib[Config.Server.thumbnail.processingLibrary] + '\' node module is not found.' +
|
' \'' + ThumbnailProcessingLib[Config.Server.thumbnail.processingLibrary] + '\' node module is not found.' +
|
||||||
' Falling back temporally to JS based thumbnail generation');
|
' Falling back temporally to JS based thumbnail generation');
|
||||||
@ -143,51 +149,57 @@ export class ConfigDiagnostics {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testThumbnailFolder(Config.Server.thumbnail.folder);
|
await ConfigDiagnostics.testThumbnailFolder(Config.Server.thumbnail.folder);
|
||||||
} catch (err) {
|
} catch (ex) {
|
||||||
NotificationManager.error('Thumbnail folder error', err);
|
const err: Error = ex;
|
||||||
Logger.error(LOG_TAG, 'Thumbnail folder error', err);
|
NotificationManager.error('Thumbnail folder error', err.toString());
|
||||||
|
Logger.error(LOG_TAG, 'Thumbnail folder error', err.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testImageFolder(Config.Server.imagesFolder);
|
await ConfigDiagnostics.testImageFolder(Config.Server.imagesFolder);
|
||||||
} catch (err) {
|
} catch (ex) {
|
||||||
NotificationManager.error('Images folder error', err);
|
const err: Error = ex;
|
||||||
Logger.error(LOG_TAG, 'Images folder error', err);
|
NotificationManager.error('Images folder error', err.toString());
|
||||||
|
Logger.error(LOG_TAG, 'Images folder error', err.toString());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testClientThumbnailConfig(Config.Client.Thumbnail);
|
await ConfigDiagnostics.testClientThumbnailConfig(Config.Client.Thumbnail);
|
||||||
} catch (err) {
|
} catch (ex) {
|
||||||
NotificationManager.error('Thumbnail settings error', err);
|
const err: Error = ex;
|
||||||
Logger.error(LOG_TAG, 'Thumbnail settings error', err);
|
NotificationManager.error('Thumbnail settings error', err.toString());
|
||||||
|
Logger.error(LOG_TAG, 'Thumbnail settings error', err.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testSearchConfig(Config.Client.Search, Config);
|
await ConfigDiagnostics.testSearchConfig(Config.Client.Search, Config);
|
||||||
} catch (err) {
|
} catch (ex) {
|
||||||
|
const err: Error = ex;
|
||||||
NotificationManager.warning('Search is not supported with these settings. Disabling temporally. ' +
|
NotificationManager.warning('Search is not supported with these settings. Disabling temporally. ' +
|
||||||
'Please adjust the config properly.', err);
|
'Please adjust the config properly.', err.toString());
|
||||||
Logger.warn(LOG_TAG, 'Search is not supported with these settings, switching off..', err);
|
Logger.warn(LOG_TAG, 'Search is not supported with these settings, switching off..', err.toString());
|
||||||
Config.Client.Search.enabled = false;
|
Config.Client.Search.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testSharingConfig(Config.Client.Sharing, Config);
|
await ConfigDiagnostics.testSharingConfig(Config.Client.Sharing, Config);
|
||||||
} catch (err) {
|
} catch (ex) {
|
||||||
|
const err: Error = ex;
|
||||||
NotificationManager.warning('Sharing is not supported with these settings. Disabling temporally. ' +
|
NotificationManager.warning('Sharing is not supported with these settings. Disabling temporally. ' +
|
||||||
'Please adjust the config properly.', err);
|
'Please adjust the config properly.', err.toString());
|
||||||
Logger.warn(LOG_TAG, 'Sharing is not supported with these settings, switching off..', err);
|
Logger.warn(LOG_TAG, 'Sharing is not supported with these settings, switching off..', err.toString());
|
||||||
Config.Client.Sharing.enabled = false;
|
Config.Client.Sharing.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ConfigDiagnostics.testMapConfig(Config.Client.Map);
|
await ConfigDiagnostics.testMapConfig(Config.Client.Map);
|
||||||
} catch (err) {
|
} catch (ex) {
|
||||||
|
const err: Error = ex;
|
||||||
NotificationManager.warning('Maps is not supported with these settings. Disabling temporally. ' +
|
NotificationManager.warning('Maps is not supported with these settings. Disabling temporally. ' +
|
||||||
'Please adjust the config properly.', err);
|
'Please adjust the config properly.', err.toString());
|
||||||
Logger.warn(LOG_TAG, 'Maps is not supported with these settings. Disabling temporally. ' +
|
Logger.warn(LOG_TAG, 'Maps is not supported with these settings. Disabling temporally. ' +
|
||||||
'Please adjust the config properly.', err);
|
'Please adjust the config properly.', err.toString());
|
||||||
Config.Client.Map.enabled = false;
|
Config.Client.Map.enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,9 +2,10 @@ import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
|
|||||||
import {UserRoles} from '../../common/entities/UserDTO';
|
import {UserRoles} from '../../common/entities/UserDTO';
|
||||||
import {RenderingMWs} from '../middlewares/RenderingMWs';
|
import {RenderingMWs} from '../middlewares/RenderingMWs';
|
||||||
import {SharingMWs} from '../middlewares/SharingMWs';
|
import {SharingMWs} from '../middlewares/SharingMWs';
|
||||||
|
import * as express from 'express';
|
||||||
|
|
||||||
export class SharingRouter {
|
export class SharingRouter {
|
||||||
public static route(app: any) {
|
public static route(app: express.Express) {
|
||||||
|
|
||||||
this.addShareLogin(app);
|
this.addShareLogin(app);
|
||||||
this.addGetSharing(app);
|
this.addGetSharing(app);
|
||||||
@ -12,7 +13,7 @@ export class SharingRouter {
|
|||||||
this.addUpdateSharing(app);
|
this.addUpdateSharing(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static addShareLogin(app) {
|
private static addShareLogin(app: express.Express) {
|
||||||
app.post('/api/share/login',
|
app.post('/api/share/login',
|
||||||
AuthenticationMWs.inverseAuthenticate,
|
AuthenticationMWs.inverseAuthenticate,
|
||||||
AuthenticationMWs.shareLogin,
|
AuthenticationMWs.shareLogin,
|
||||||
@ -20,7 +21,7 @@ export class SharingRouter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static addGetSharing(app) {
|
private static addGetSharing(app: express.Express) {
|
||||||
app.get('/api/share/:sharingKey',
|
app.get('/api/share/:sharingKey',
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.LimitedGuest),
|
AuthenticationMWs.authorise(UserRoles.LimitedGuest),
|
||||||
@ -29,7 +30,7 @@ export class SharingRouter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static addCreateSharing(app) {
|
private static addCreateSharing(app: express.Express) {
|
||||||
app.post(['/api/share/:directory(*)', '/api/share/', '/api/share//'],
|
app.post(['/api/share/:directory(*)', '/api/share/', '/api/share//'],
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.User),
|
AuthenticationMWs.authorise(UserRoles.User),
|
||||||
@ -38,7 +39,7 @@ export class SharingRouter {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static addUpdateSharing(app) {
|
private static addUpdateSharing(app: express.Express) {
|
||||||
app.put(['/api/share/:directory(*)', '/api/share/', '/api/share//'],
|
app.put(['/api/share/:directory(*)', '/api/share/', '/api/share//'],
|
||||||
AuthenticationMWs.authenticate,
|
AuthenticationMWs.authenticate,
|
||||||
AuthenticationMWs.authorise(UserRoles.User),
|
AuthenticationMWs.authorise(UserRoles.User),
|
||||||
|
|||||||
@ -27,7 +27,7 @@ const LOG_TAG = '[server]';
|
|||||||
|
|
||||||
export class Server {
|
export class Server {
|
||||||
|
|
||||||
private app: any;
|
private app: _express.Express;
|
||||||
private server: any;
|
private server: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -15,7 +15,8 @@ export class ShareSettingsService extends AbstractSettingsService<ClientConfig.S
|
|||||||
|
|
||||||
|
|
||||||
public isSupported(): boolean {
|
public isSupported(): boolean {
|
||||||
return this._settingsService.settings.value.Server.database.type !== DatabaseType.memory;
|
return this._settingsService.settings.value.Server.database.type !== DatabaseType.memory &&
|
||||||
|
this._settingsService.settings.value.Client.authenticationRequired === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateSettings(settings: ClientConfig.SharingConfig): Promise<void> {
|
public updateSettings(settings: ClientConfig.SharingConfig): Promise<void> {
|
||||||
|
|||||||
@ -46,7 +46,7 @@
|
|||||||
"winston": "2.4.2"
|
"winston": "2.4.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@agm/core": "1.0.0-beta.2",
|
"@agm/core": "1.0.0-beta.3",
|
||||||
"@angular-devkit/build-angular": "~0.6.3",
|
"@angular-devkit/build-angular": "~0.6.3",
|
||||||
"@angular/animations": "6.0.3",
|
"@angular/animations": "6.0.3",
|
||||||
"@angular/cli": "6.0.3",
|
"@angular/cli": "6.0.3",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user