Browse Source

WIP accounts_server.js until line 800. Repaired Arunoda demo.

Frederic G. MARAND 9 years ago
parent
commit
c44f494e30
3 changed files with 74 additions and 13 deletions
  1. 2 1
      .meteor/packages
  2. 62 3
      docs/accounts-base/README.md
  3. 10 9
      server/admin.js

+ 2 - 1
.meteor/packages

@@ -16,6 +16,7 @@ standard-minifiers      # JS/CSS minifiers run for production mode
 es5-shim                # ECMAScript 5 compatibility for older browsers.
 ecmascript              # Enable ECMAScript2015+ syntax in app code
 
-autopublish             # Publish all data to the clients (for prototyping)
 insecure                # Allow all DB writes from clients (for prototyping)
 accounts-ui
+check
+autopublish

File diff suppressed because it is too large
+ 62 - 3
docs/accounts-base/README.md


+ 10 - 9
server/admin.js

@@ -1,23 +1,24 @@
-Accounts.registerLoginHandler(function (loginRequest) {
-  Meteor._debug("Server registerLoginHandler", loginRequest);
+Accounts.registerLoginHandler("adminHandler", function (loginRequest) {
+  Meteor._debug("Server registerLoginHandler, request", loginRequest);
   // There are multiple login handlers in Meteor.
   // A login request goes through all these handlers to find its login handler.
   // So in our login handler, we only consider login requests which have an
   // "admin" field.
   let result;
   if (!loginRequest.admin) {
-    result = void 0;
-    Meteor._debug("Server registerLoginHandler, returning", result);
+    result = undefined;
+    Meteor._debug("Server registerLoginHandler for non-admin, returning", result);
     return result;
   }
 
   // Our authentication logic.
-  if (loginRequest.password.password !== "admin-password") {
-    result = null;
-    Meteor._debug("Server registerLoginHandler, returning", result);
+  if (loginRequest.password !== "admin-password") {
+    result = { error: new Meteor.Error(400, "Incorrect password") };
+    Meteor._debug("Server registerLoginHandler for bad password, returning", result);
     return result;
   }
 
+  Meteor._debug("Server registerLoginHandler for good password, continuing");
   // We create an admin user if none exists, and get its userId.
   let userId;
   let user = Meteor.users.findOne({ username: "admin" });
@@ -29,8 +30,8 @@ Accounts.registerLoginHandler(function (loginRequest) {
   }
   // Send logged-in user's id.
   result = {
-    id: userId
+    userId: userId
   };
-  Meteor._debug("Server registerLoginHandler, returning", result);
+  Meteor._debug("Server registerLoginHandler allowed, returning", result);
   return result;
 });

Some files were not shown because too many files changed in this diff