Просмотр исходного кода

use form validator for revision when pageEdit

Yuki Takei 7 лет назад
Родитель
Сommit
850b591451
2 измененных файлов с 14 добавлено и 2 удалено
  1. 7 2
      lib/routes/page.js
  2. 7 0
      lib/views/widget/page_alerts.html

+ 7 - 2
lib/routes/page.js

@@ -607,11 +607,16 @@ module.exports = function(crowi, app) {
 
 
   actions.pageEdit = function(req, res) {
   actions.pageEdit = function(req, res) {
 
 
-    var pageForm = req.body.pageForm;
+    if (!req.form.isValid) {
+      req.flash('dangerMessage', 'Request is invalid.');
+      return res.redirect(req.headers.referer);
+    }
+
+    var pageForm = req.form.pageForm;
+    var path = pageForm.path;
     var body = pageForm.body;
     var body = pageForm.body;
     var currentRevision = pageForm.currentRevision;
     var currentRevision = pageForm.currentRevision;
     var grant = pageForm.grant;
     var grant = pageForm.grant;
-    var path = pageForm.path;
     var grantUserGroupId = pageForm.grantUserGroupId;
     var grantUserGroupId = pageForm.grantUserGroupId;
 
 
     // TODO: make it pluggable
     // TODO: make it pluggable

+ 7 - 0
lib/views/widget/page_alerts.html

@@ -79,5 +79,12 @@
       <a href="{{ page.path }}"><i class="icon-fw icon-arrow-right-circle"></i>{{ t('Show latest') }}</a>
       <a href="{{ page.path }}"><i class="icon-fw icon-arrow-right-circle"></i>{{ t('Show latest') }}</a>
     </div>
     </div>
     {% endif %}
     {% endif %}
+
+    {% set dmessage = req.flash('dangerMessage') %}
+    {% if dmessage.length %}
+    <div class="alert alert-danger m-b-15">
+      {{ dmessage }}
+    </div>
+    {% endif %}
   </div>
   </div>
 </div>
 </div>