Commits

benoitc  committed 6c2eb57

fix validation. sucess != success

  • Participants
  • Parent commits 59ed10d
  • Branches couchdb010

Comments (0)

Files changed (3)

File _attachments/login.html

 <body>
     <div id="container">
         <form name="flogin" id="flogin" action="/_session" method="post">
-            <!--<input type="hidden" id="next" value="_list/index/recent-posts?descending=true&limit=8">-->
             <ul>
                 <li><label for="username">username</label><input type="text" id="username" name="username" value=""></li>
                 <li><label for="password">password</label><input type="password" id="password" name="password" value=""></li>

File validate_doc_update.js

     if (!beTrue) forbidden(message);
   };
 
-  if (doc_type != "comment" && !userCtx.name)
+  if ((doc_type != "comment") && !userCtx.name)
       forbidden("only connected users can create such doc");
 
   // docs with authors can only be saved by their author
-  if (authori && userCtx.roles.indexOf('_admin') == -1) {
+  if (author && (userCtx.roles.indexOf('_admin') == -1)) {
       // admin can edit anything, only check when not admin...
       if ((oldDoc && oldDoc.author != newDoc.author))
         forbidden("You may not change the author of a doc.");
 
       if (author != userCtx.name)
         forbidden("Only "+author+" may edit this document.");      
-    } 
+     
   }
 
   // authors and admins can always delete
   if (oldDoc && oldDoc.created_at != newDoc.created_at)
     forbidden("You may not change the created_at field of a doc.");
   
-  //if (newDoc.created_at) {
-  //  if (!newDoc.created_at.match(/\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} \+0000/))
-  //    forbidden("Sorry, "+newDoc.created_at+" is not a valid date format. Try: 2008/12/10 21:16:02 +0000");
-  //}
+
     
   if (doc_type == 'post') {
     // post required fields

File vendor/inditeweb/_attachments/jquery.couchapp.js

           
         },
         get_session: function() {
-            var session = {};
+            var _session_data = {};
+
             $.ajax({
                 url: "/_session",
+                type: "GET", 
                 async: false,
                 dataType: "json",
-                sucess: function(data) {
-                    session = data;
+                beforeSend: function(req) {
+                    req.setRequestHeader('X-CouchDB-WWW-Authenticate', 'Cookie');
+                },
+                success: function(data) {
+                    _session_data = data;
                 }
             });
-            return session;
+            return _session_data;
         },
         name: dname,
         db : db,