1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-12 04:23:09 +02:00

fixing sharing settings error

This commit is contained in:
Patrik J. Braun 2018-05-24 21:29:05 -04:00
parent 999ca21519
commit 4afff63415
7 changed files with 50 additions and 33 deletions

View File

@ -1 +1 @@
web: node ./backend/index.js --Client-authenticationRequired=false
web: node ./backend/index.js --Client-authenticationRequired=false --Client-Sharing-enabled=false

View File

@ -136,6 +136,9 @@ export class AdminMWs {
// only updating explicitly set config (not saving config set by the diagnostics)
const original = Config.original();
original.Client.authenticationRequired = <boolean>req.body.settings;
if (original.Client.authenticationRequired === false) {
original.Client.Sharing.enabled = false;
}
original.save();
await ConfigDiagnostics.runDiagnostics();
Logger.info(LOG_TAG, 'new config:');

View File

@ -104,6 +104,10 @@ export class ConfigDiagnostics {
config.Server.database.type === DatabaseType.memory) {
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) {
@ -118,10 +122,11 @@ export class ConfigDiagnostics {
if (Config.Server.database.type !== DatabaseType.memory) {
try {
await ConfigDiagnostics.testDatabase(Config.Server.database);
} catch (err) {
Logger.warn(LOG_TAG, '[SQL error]', err);
} catch (ex) {
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');
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);
}
}
@ -129,11 +134,12 @@ export class ConfigDiagnostics {
if (Config.Server.thumbnail.processingLibrary !== ThumbnailProcessingLib.Jimp) {
try {
await ConfigDiagnostics.testThumbnailLib(Config.Server.thumbnail.processingLibrary);
} catch (err) {
} catch (ex) {
const err: Error = ex;
NotificationManager.warning('Thumbnail hardware acceleration is not possible.' +
' \'' + ThumbnailProcessingLib[Config.Server.thumbnail.processingLibrary] + '\' node module is not found.' +
' Falling back temporally to JS based thumbnail generation', err);
Logger.warn(LOG_TAG, '[Thumbnail hardware acceleration] module error: ', err);
' Falling back temporally to JS based thumbnail generation', err.toString());
Logger.warn(LOG_TAG, '[Thumbnail hardware acceleration] module error: ', err.toString());
Logger.warn(LOG_TAG, 'Thumbnail hardware acceleration is not possible.' +
' \'' + ThumbnailProcessingLib[Config.Server.thumbnail.processingLibrary] + '\' node module is not found.' +
' Falling back temporally to JS based thumbnail generation');
@ -143,51 +149,57 @@ export class ConfigDiagnostics {
try {
await ConfigDiagnostics.testThumbnailFolder(Config.Server.thumbnail.folder);
} catch (err) {
NotificationManager.error('Thumbnail folder error', err);
Logger.error(LOG_TAG, 'Thumbnail folder error', err);
} catch (ex) {
const err: Error = ex;
NotificationManager.error('Thumbnail folder error', err.toString());
Logger.error(LOG_TAG, 'Thumbnail folder error', err.toString());
}
try {
await ConfigDiagnostics.testImageFolder(Config.Server.imagesFolder);
} catch (err) {
NotificationManager.error('Images folder error', err);
Logger.error(LOG_TAG, 'Images folder error', err);
} catch (ex) {
const err: Error = ex;
NotificationManager.error('Images folder error', err.toString());
Logger.error(LOG_TAG, 'Images folder error', err.toString());
}
try {
await ConfigDiagnostics.testClientThumbnailConfig(Config.Client.Thumbnail);
} catch (err) {
NotificationManager.error('Thumbnail settings error', err);
Logger.error(LOG_TAG, 'Thumbnail settings error', err);
} catch (ex) {
const err: Error = ex;
NotificationManager.error('Thumbnail settings error', err.toString());
Logger.error(LOG_TAG, 'Thumbnail settings error', err.toString());
}
try {
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. ' +
'Please adjust the config properly.', err);
Logger.warn(LOG_TAG, 'Search is not supported with these settings, switching off..', err);
'Please adjust the config properly.', err.toString());
Logger.warn(LOG_TAG, 'Search is not supported with these settings, switching off..', err.toString());
Config.Client.Search.enabled = false;
}
try {
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. ' +
'Please adjust the config properly.', err);
Logger.warn(LOG_TAG, 'Sharing is not supported with these settings, switching off..', err);
'Please adjust the config properly.', err.toString());
Logger.warn(LOG_TAG, 'Sharing is not supported with these settings, switching off..', err.toString());
Config.Client.Sharing.enabled = false;
}
try {
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. ' +
'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. ' +
'Please adjust the config properly.', err);
'Please adjust the config properly.', err.toString());
Config.Client.Map.enabled = false;
}

View File

@ -2,9 +2,10 @@ import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
import {UserRoles} from '../../common/entities/UserDTO';
import {RenderingMWs} from '../middlewares/RenderingMWs';
import {SharingMWs} from '../middlewares/SharingMWs';
import * as express from 'express';
export class SharingRouter {
public static route(app: any) {
public static route(app: express.Express) {
this.addShareLogin(app);
this.addGetSharing(app);
@ -12,7 +13,7 @@ export class SharingRouter {
this.addUpdateSharing(app);
}
private static addShareLogin(app) {
private static addShareLogin(app: express.Express) {
app.post('/api/share/login',
AuthenticationMWs.inverseAuthenticate,
AuthenticationMWs.shareLogin,
@ -20,7 +21,7 @@ export class SharingRouter {
);
}
private static addGetSharing(app) {
private static addGetSharing(app: express.Express) {
app.get('/api/share/:sharingKey',
AuthenticationMWs.authenticate,
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//'],
AuthenticationMWs.authenticate,
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//'],
AuthenticationMWs.authenticate,
AuthenticationMWs.authorise(UserRoles.User),

View File

@ -27,7 +27,7 @@ const LOG_TAG = '[server]';
export class Server {
private app: any;
private app: _express.Express;
private server: any;
/**

View File

@ -15,7 +15,8 @@ export class ShareSettingsService extends AbstractSettingsService<ClientConfig.S
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> {

View File

@ -46,7 +46,7 @@
"winston": "2.4.2"
},
"devDependencies": {
"@agm/core": "1.0.0-beta.2",
"@agm/core": "1.0.0-beta.3",
"@angular-devkit/build-angular": "~0.6.3",
"@angular/animations": "6.0.3",
"@angular/cli": "6.0.3",