2018-03-30 15:30:30 -04:00
|
|
|
import {AuthenticationMWs} from '../middlewares/user/AuthenticationMWs';
|
|
|
|
import {UserRoles} from '../../common/entities/UserDTO';
|
|
|
|
import {RenderingMWs} from '../middlewares/RenderingMWs';
|
|
|
|
import {SharingMWs} from '../middlewares/SharingMWs';
|
2018-05-24 21:29:05 -04:00
|
|
|
import * as express from 'express';
|
2018-11-30 15:36:42 +01:00
|
|
|
import {QueryParams} from '../../common/QueryParams';
|
2016-03-19 17:31:42 +01:00
|
|
|
|
2016-05-09 17:04:56 +02:00
|
|
|
export class SharingRouter {
|
2018-05-24 21:29:05 -04:00
|
|
|
public static route(app: express.Express) {
|
2016-03-19 17:31:42 +01:00
|
|
|
|
2017-07-09 12:03:17 +02:00
|
|
|
this.addShareLogin(app);
|
2017-06-10 22:32:56 +02:00
|
|
|
this.addGetSharing(app);
|
2017-07-03 19:17:49 +02:00
|
|
|
this.addCreateSharing(app);
|
2017-06-10 22:32:56 +02:00
|
|
|
this.addUpdateSharing(app);
|
|
|
|
}
|
2016-03-19 17:31:42 +01:00
|
|
|
|
2018-05-24 21:29:05 -04:00
|
|
|
private static addShareLogin(app: express.Express) {
|
2018-03-30 15:30:30 -04:00
|
|
|
app.post('/api/share/login',
|
2017-07-09 12:03:17 +02:00
|
|
|
AuthenticationMWs.inverseAuthenticate,
|
|
|
|
AuthenticationMWs.shareLogin,
|
|
|
|
RenderingMWs.renderSessionUser
|
|
|
|
);
|
2018-05-12 12:19:51 -04:00
|
|
|
}
|
2017-07-09 12:03:17 +02:00
|
|
|
|
2018-05-24 21:29:05 -04:00
|
|
|
private static addGetSharing(app: express.Express) {
|
2018-11-30 15:36:42 +01:00
|
|
|
app.get('/api/share/:' + QueryParams.gallery.sharingKey_long,
|
2017-06-10 22:32:56 +02:00
|
|
|
AuthenticationMWs.authenticate,
|
2017-07-09 12:03:17 +02:00
|
|
|
AuthenticationMWs.authorise(UserRoles.LimitedGuest),
|
2017-07-03 19:17:49 +02:00
|
|
|
SharingMWs.getSharing,
|
|
|
|
RenderingMWs.renderSharing
|
|
|
|
);
|
2018-05-12 12:19:51 -04:00
|
|
|
}
|
2017-07-03 19:17:49 +02:00
|
|
|
|
2018-05-24 21:29:05 -04:00
|
|
|
private static addCreateSharing(app: express.Express) {
|
2018-03-30 15:30:30 -04:00
|
|
|
app.post(['/api/share/:directory(*)', '/api/share/', '/api/share//'],
|
2017-07-03 19:17:49 +02:00
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
AuthenticationMWs.authorise(UserRoles.User),
|
|
|
|
SharingMWs.createSharing,
|
|
|
|
RenderingMWs.renderSharing
|
2017-06-10 22:32:56 +02:00
|
|
|
);
|
2018-05-12 12:19:51 -04:00
|
|
|
}
|
2016-03-19 17:31:42 +01:00
|
|
|
|
2018-05-24 21:29:05 -04:00
|
|
|
private static addUpdateSharing(app: express.Express) {
|
2018-03-30 15:30:30 -04:00
|
|
|
app.put(['/api/share/:directory(*)', '/api/share/', '/api/share//'],
|
2017-06-10 22:32:56 +02:00
|
|
|
AuthenticationMWs.authenticate,
|
2017-07-03 19:17:49 +02:00
|
|
|
AuthenticationMWs.authorise(UserRoles.User),
|
|
|
|
SharingMWs.updateSharing,
|
|
|
|
RenderingMWs.renderSharing
|
2017-06-10 22:32:56 +02:00
|
|
|
);
|
2018-05-12 12:19:51 -04:00
|
|
|
}
|
2016-03-19 17:31:42 +01:00
|
|
|
|
2017-06-10 22:32:56 +02:00
|
|
|
}
|