Przeglądaj źródła

pass certify-shared-page

itizawa 5 lat temu
rodzic
commit
794d964af9

+ 1 - 1
src/client/js/app.jsx

@@ -141,7 +141,7 @@ $('a[data-toggle="tab"][href="#revision-history"]').on('show.bs.tab', () => {
   ReactDOM.render(
     <I18nextProvider i18n={i18n}>
       <ErrorBoundary>
-        <PageHistory pageId={pageContainer.state.pageId} crowi={appContainer} />
+        <PageHistory shareLinkId={pageContainer.state.shareLinkId} pageId={pageContainer.state.pageId} crowi={appContainer} />
       </ErrorBoundary>
     </I18nextProvider>, document.getElementById('revision-history'),
   );

+ 4 - 2
src/client/js/components/PageHistory.jsx

@@ -26,7 +26,7 @@ class PageHistory extends React.Component {
 
   async componentWillMount() {
     const pageId = this.props.pageId;
-
+    const shareLinkId = this.props.shareLinkId || null;
     if (!pageId) {
       return;
     }
@@ -34,7 +34,7 @@ class PageHistory extends React.Component {
     let res;
     try {
       this.setState({ isLoading: true });
-      res = await this.props.crowi.apiGet('/revisions.ids', { page_id: pageId });
+      res = await this.props.crowi.apiGet('/revisions.ids', { page_id: pageId, share_link_id: shareLinkId });
     }
     catch (err) {
       logger.error(err);
@@ -166,6 +166,8 @@ class PageHistory extends React.Component {
 
 PageHistory.propTypes = {
   t: PropTypes.func.isRequired, // i18next
+
+  shareLinkId: PropTypes.string,
   pageId: PropTypes.string,
   crowi: PropTypes.object.isRequired,
 };

+ 3 - 2
src/server/middlewares/certify-shared-page.js

@@ -6,12 +6,13 @@ module.exports = (crowi) => {
 
   return async(req, res, next) => {
     const pageId = req.query.page_id || req.body.page_id || null;
-    if (pageId == null) {
+    const shareLinkId = req.query.share_link_id || req.body.share_link_id || null;
+    if (pageId == null || shareLinkId == null) {
       return next();
     }
 
     const ShareLink = crowi.model('ShareLink');
-    const sharelink = await ShareLink.findOne({ relatedPage: pageId });
+    const sharelink = await ShareLink.findOne({ _id: shareLinkId, relatedPage: pageId });
 
     // check sharelink enabled
     if (sharelink == null || sharelink.isExpired()) {

+ 1 - 1
src/server/routes/index.js

@@ -167,7 +167,7 @@ module.exports = function(crowi, app) {
 
   app.get('/_api/revisions.get'       , accessTokenParser , loginRequired , revision.api.get);
   app.get('/_api/revisions.ids'       , certifySharedPage , accessTokenParser , loginRequired , revision.api.ids);
-  app.get('/_api/revisions.list'      , accessTokenParser , loginRequired , revision.api.list);
+  app.get('/_api/revisions.list'      , certifySharedPage , accessTokenParser , loginRequired , revision.api.list);
 
   app.get('/trash$'                   , loginRequired , page.trashPageShowWrapper);
   app.get('/trash/$'                  , loginRequired , page.trashPageListShowWrapper);