2016-05-26 02:17:42 +08:00
|
|
|
import {AuthenticationMWs} from "../middlewares/user/AuthenticationMWs";
|
2016-12-27 23:09:47 +08:00
|
|
|
import {UserRoles} from "../../common/entities/UserDTO";
|
2017-07-04 01:17:49 +08:00
|
|
|
import {RenderingMWs} from "../middlewares/RenderingMWs";
|
|
|
|
import {SharingMWs} from "../middlewares/SharingMWs";
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2016-05-09 23:04:56 +08:00
|
|
|
export class SharingRouter {
|
2017-06-11 04:32:56 +08:00
|
|
|
public static route(app: any) {
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-07-09 18:03:17 +08:00
|
|
|
this.addShareLogin(app);
|
2017-06-11 04:32:56 +08:00
|
|
|
this.addGetSharing(app);
|
2017-07-04 01:17:49 +08:00
|
|
|
this.addCreateSharing(app);
|
2017-06-11 04:32:56 +08:00
|
|
|
this.addUpdateSharing(app);
|
|
|
|
}
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-07-09 18:03:17 +08:00
|
|
|
private static addShareLogin(app) {
|
|
|
|
app.post("/api/share/login",
|
|
|
|
AuthenticationMWs.inverseAuthenticate,
|
|
|
|
AuthenticationMWs.shareLogin,
|
|
|
|
RenderingMWs.renderSessionUser
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addGetSharing(app) {
|
2017-07-04 01:17:49 +08:00
|
|
|
app.get("/api/share/:sharingKey",
|
2017-06-11 04:32:56 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2017-07-09 18:03:17 +08:00
|
|
|
AuthenticationMWs.authorise(UserRoles.LimitedGuest),
|
2017-07-04 01:17:49 +08:00
|
|
|
SharingMWs.getSharing,
|
|
|
|
RenderingMWs.renderSharing
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
private static addCreateSharing(app) {
|
|
|
|
app.post(["/api/share/:directory(*)", "/api/share/", "/api/share//"],
|
|
|
|
AuthenticationMWs.authenticate,
|
|
|
|
AuthenticationMWs.authorise(UserRoles.User),
|
|
|
|
SharingMWs.createSharing,
|
|
|
|
RenderingMWs.renderSharing
|
2017-06-11 04:32:56 +08:00
|
|
|
);
|
|
|
|
};
|
2016-03-20 00:31:42 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
private static addUpdateSharing(app) {
|
2017-07-04 01:17:49 +08:00
|
|
|
app.put(["/api/share/:directory(*)", "/api/share/", "/api/share//"],
|
2017-06-11 04:32:56 +08:00
|
|
|
AuthenticationMWs.authenticate,
|
2017-07-04 01:17:49 +08:00
|
|
|
AuthenticationMWs.authorise(UserRoles.User),
|
|
|
|
SharingMWs.updateSharing,
|
|
|
|
RenderingMWs.renderSharing
|
2017-06-11 04:32:56 +08:00
|
|
|
);
|
|
|
|
};
|
2016-03-20 00:31:42 +08:00
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|