Browse Source

Creating a complete user beyond the id field.

Frederic G. MARAND 9 years ago
parent
commit
c17688a5e5
5 changed files with 16 additions and 6 deletions
  1. 1 0
      .meteor/packages
  2. 5 0
      .meteor/versions
  3. 1 1
      client/admin.js
  4. 4 3
      docs/accounts-base/README.md
  5. 5 2
      server/admin.js

+ 1 - 0
.meteor/packages

@@ -20,3 +20,4 @@ insecure                # Allow all DB writes from clients (for prototyping)
 accounts-ui
 check
 autopublish
+accounts-facebook

+ 5 - 0
.meteor/versions

@@ -1,4 +1,6 @@
 accounts-base@1.2.2
+accounts-facebook@1.0.6
+accounts-oauth@1.1.8
 accounts-ui@1.1.6
 accounts-ui-unstyled@1.1.8
 autopublish@1.0.4
@@ -26,6 +28,7 @@ ecmascript@0.1.6
 ecmascript-runtime@0.2.6
 ejson@1.0.7
 es5-shim@4.1.14
+facebook@1.2.2
 fastclick@1.0.7
 geojson-utils@1.0.4
 hot-code-push@1.0.0
@@ -49,6 +52,8 @@ mobile-status-bar@1.0.6
 mongo@1.1.3
 mongo-id@1.0.1
 npm-mongo@1.4.39_1
+oauth@1.1.6
+oauth2@1.1.5
 observe-sequence@1.0.7
 ordered-dict@1.0.4
 promise@0.5.1

+ 1 - 1
client/admin.js

@@ -1,7 +1,7 @@
 Meteor.loginAsAdmin = function (password, callback) {
   // Create a login request with admin:true, so our loginHandler can handle it.
   let loginRequest = { admin: true, password: password };
-  Meteor._debug('Client loginAsAdmin');
+  Meteor._debug('Client loginAsAdmin, pass:', password);
   // Send the login request.
   Accounts.callLoginMethod({
     methodArguments: [loginRequest],

+ 4 - 3
docs/accounts-base/README.md

@@ -139,11 +139,12 @@ Base class for `AccountsClient` / `AccountsServer`.
 * `setupUsersCollection(users)` : configures the `users` collection obtained from the parent constructor, by applying `users.allow` to limite update rights to the document for the current user, and ensuring multiple MongoDB indexes.
 * `updateOrCreateUserFromExternalService(serviceName, serviceData, options)`: Updates or creates a user after we authenticate with a 3rd party.
     * `@param serviceName` {String} Service name (eg, twitter).
-    * `@param serviceData` {Object} Data to store in the user's record under services[serviceName]. Must include an "id" field which is a unique identifier for the user in the service.
+    * `@param serviceData` {Object} Data to store in the user's record under services[serviceName]. Must include an "id" field which is a unique identifier for the user in the service. (Side note: there is a specific kludge for old Twitter ids).
     * `@param options` {Object, optional} Other options to pass to insertUserDoc (eg, profile)
-    * `@returns` {Object} Object with token and id keys, like the result of the "login" method.
+    * `@returns` {Object} Object with `token` and `id` (actually `userId`) keys, like the result of the `login` method.
     * "internal" services `resume` and `password` may not use this
-    *
+    * does NOT update `profile` but updates `serviceData`
+    * Not completely stable. Per docs: _XXX provide an onUpdateUser hook which would let apps update the profile too_
 
 * `userId()`: overrides the unimplemented version in `AccountsCommon`. This function only works if called inside a method, throws otherwise.
 * `usingOAuthEncryption()`: is OAuth encryption present AND is a key loaded ?

+ 5 - 2
server/admin.js

@@ -32,6 +32,9 @@ Accounts.registerLoginHandler("adminHandler", function (loginRequest) {
   result = {
     userId: userId
   };
-  Meteor._debug("Server registerLoginHandler allowed, returning", result);
-  return result;
+  Meteor._debug("Server registerLoginHandler allowed, returning:", result);
+  return Accounts.updateOrCreateUserFromExternalService('drupal', {
+    id: 1,
+    roles: ['authenticated user', 'administrator']
+    }, {});
 });