Commit Graph

1742 Commits

Author SHA1 Message Date
Avital Oliver
38fb1dfd01 accounts-ui improvements
- additional class on the element with class "login-link-and-dropdown-list"
  with information about which of the three password flows we are in
- a wrapper element around each label/input pair in the password forms
- links to go back to the sign up flow from create account or forgot password
2012-10-08 23:39:48 -07:00
Avital Oliver
200089e1b6 accounts-ui: apply same fonts to dialogs 2012-10-08 23:30:14 -07:00
David Glasser
2caff12c36 Hide fields and button on a successful password change. 2012-10-08 23:08:53 -07:00
David Glasser
139b611b8b Fix change passwords flow (bug introduced in 147ef71).
Improve error reporting in Meteor.flush.
2012-10-08 22:56:12 -07:00
David Glasser
ef70084e83 Make sure that "reset password" links validate the correct email address. 2012-10-08 22:29:28 -07:00
David Glasser
c394f9a544 Accounts.changePassword: consistently allow no callback to be passed. 2012-10-08 22:29:28 -07:00
David Glasser
8d21e2c5b7 Move email validation tokens into the users doc. 2012-10-08 22:29:28 -07:00
David Glasser
e8e880566e Add a comment about disconnecting sessions when users or login tokens are deleted. 2012-10-08 22:29:28 -07:00
David Glasser
1333b9308a Move "resume" login tokens from a separate collection into the user doc.
Include timestamps with the tokens, so that later we can set expiry/cleanup
policies.

Observable changes:

 - tokens can no longer be used to log in as a user which no longer exists

 - when you log in with a "reset password" link, all logins in other browsers
   lose the ability to reconnect. However, other browser logins are not
   immediately disconnected, and "change password" does not invalidate any
   tokens.
2012-10-08 22:29:28 -07:00
David Glasser
d4e4a6300a Change interface for determining if the user doc is loaded to a new reactive
function Meteor.userLoaded(), which is true if you are logged in and the user
doc is loaded, and a currentUserLoaded Handlebars helper to match.

If logged in and the user doc is not yet loaded, Meteor.user() now returns an
object which only contains _id.

The current user subscription is now named meteor.currentUser rather than being
an unnamed sub. (loginServiceConfiguration is renamed
meteor.loginServiceConfiguration to match.) This subscription is sub'd from when
you log in and unsub'd from when you log out (or if you log in with different
credentials).

I was very careful to make sure that in the case of "sub #1, unsub #1, sub #2,
sub #1 is ready" we do not declare the user to be ready. I could have instead
modified livedata_connection to not call ready callbacks for unsub'd
subscriptions (add a "delete self.sub_ready_callbacks[obj._id]" to the self.subs
removed function) but this seemed less invasive.

The password and email tests use this to take a more rigorous approach to
waiting for the data to load, and they change the localStorage keys so that
multiple tabs running tests don't interact via localStorage.
2012-10-08 21:59:14 -07:00
David Glasser
e733b17d6a Merge branch 'devel' into auth
Pull in the issue #215 fix (Sessions can contain non-scalar objects)
2012-10-08 21:43:54 -07:00
David Glasser
3b41434e23 In method invocations and publish handlers, this.userId is now the userId
itself, not a function returning it.
2012-10-08 21:41:14 -07:00
David Glasser
37201062e1 Only allow users to configure login services that are actually part of the app.
(Well, and services with names like "registerLoginHandler", but whatever.)

This prevents this attack:
  - Alice launches site with Facebook login
  - Mallory sends configureLoginService method to configure the Twitter service
  - Alice runs "meteor add accounts-twitter" and is impressed that Twitter integration
    Just Works with no configuration
  - Now the app is using Mallory's credentials
2012-10-08 20:53:49 -07:00
Avital Oliver
3c3540497c accounts: Allow specifying explicit errors in Meteor.validateNewUser 2012-10-08 19:38:20 -07:00
Avital Oliver
46fbe872d2 accounts-ui: trim login service configuration strings 2012-10-08 19:38:20 -07:00
Avital Oliver
147ef71195 Large refactor of accounts-ui
- Split login_buttons.html and login_buttons.js into multiple files
  - Specifically, make it easier to reason about the display of loginButtons whether it is in dropdown mode or not
- Split templates into subtemplates to make it easier to read the login button .html files as "tables of contents"
- Introduce Meteor._loginButtonsSession, which makes it easier to access internal session fields for loginButtons
- Unify code that calls the various Meteor.loginWithFoo() functions

Breaking change: rename "configureLoginServicesDialogForFoo" to "configureLoginServiceDialogForFoo" (in packages such as accounts-facebook)
2012-10-08 19:38:20 -07:00
David Glasser
1816a1ba74 Once an SRP challenge is verified, remove it from the session. 2012-10-08 10:42:39 -07:00
David Glasser
f13c9d18fc Rename Accounts.onCreateUserHook to Accounts.insertUserDoc; make it actually
insert the user doc instead of just returning it, and make it (optionally)
generate a login token.
2012-10-08 09:18:55 -07:00
David Glasser
779c2a5036 Move login token generation into updateOrCreateUserFromExternalService. 2012-10-08 09:18:55 -07:00
David Glasser
7b758a0c9b Rename and refactor Accounts.updateOrCreateUser.
This is an internal function only used by OAuth implementations and the
equivalent, so rename to a more specific name:
Accounts.updateOrCreateUserFromExternalService.

Change the signature to directly take serviceName and serviceData instead of a
nested data structure with a very specific structure. Similarly, change
Accounts.oauth.registerService's handleOauthRequest callback to un-nest the
service data.

Throw errors on misuse (if you try to use it with the "password" or
soon-to-be-introduced "resume" services, or if you don't provide an id).

Avoid doing no-op user updates if there is nothing new in "extra".
2012-10-08 09:18:55 -07:00
David Glasser
c80c5b8674 Incompatible auth change: Login services will need to be reconfigured.
Rename internal accounts packages to start with meteor_ (better namespacing) and
contain no dots (easier to use in Mongo shell).

We leave "users" un-namespaced but note that we will eventually allow
configuration.

Note that the two token collections may soon be merged into users.
2012-10-08 09:18:55 -07:00
David Glasser
5a01d9fe4d Meteor.Collection now takes its optional parameters ("manager" and some
undocumented ones beginning with _) in an options dictionary.

(For backwards compatibility it still supports passing the manager directly.)
2012-10-08 09:17:54 -07:00
David Glasser
8b160a1c8d Update a function name in a comment. 2012-10-07 04:06:27 -07:00
David Glasser
9251edbf8d Allow arbitrary JSON objects to be stored in Session (but not compared with equals). Test Session. Fixes #215. 2012-10-06 14:42:59 -07:00
David Glasser
204a675104 Use a _ContextSet for this.userId in livedata_connection. 2012-10-06 11:30:48 -07:00
David Glasser
c27cd57c28 Use a _ContextSet in Accounts.loginServicesConfigured. 2012-10-06 11:20:24 -07:00
David Glasser
41cc24d9e7 Merge branch 'devel' into auth
Pulls in Meteor._ContextSet, bumps version to 0.4.2, etc.
2012-10-06 11:10:56 -07:00
David Glasser
86cdbe4d71 Merge branch 'deps-utils-private' into devel
This adds three deps utilities, which are currently undocumented and internal:
Meteor._ContextSet, Meteor._autorun, and Meteor._atFlush.
2012-10-06 11:06:58 -07:00
Nick Martin
a5cc807b88 Allow changes to accounts configuration in insecure mode. It's insecure, but… well… you asked for it. Also, encourages users to write a different and better config wizard. 2012-10-05 20:26:01 -07:00
Nick Martin
4dc19aea14 Store srp challenge in sessionData, not in the database. 2012-10-05 20:21:04 -07:00
Nick Martin
04e2baa614 Add sessionData to 'this' in methods and subscriptions. Just an object that users can write to. Same scope as userId.
Also, convert MethodInvocation to options instead of long parameter list.
2012-10-05 20:21:04 -07:00
Avital Oliver
b2112ac57f accounts-ui: Show messages and errors even when accounts-password is not used
- If there are multiple external login services, show the messages at the bottom
  of the login dropdown
- If there is just one external login service, show it in a standalone dialog
2012-10-05 19:42:08 -07:00
David Glasser
20e29d2851 Make everything in deps-utils private for now. 2012-10-05 15:26:22 -07:00
David Glasser
08a0eda83e Merge branch 'devel' into deps-utils-private
Conflicts:
	packages/session/session.js
2012-10-05 15:14:13 -07:00
Avital Oliver
ace38c5ab2 Minor fix for last merge 2012-10-05 14:17:56 -07:00
Avital Oliver
b0b3f3546f Merge branch 'auth-change-password' into auth
Conflicts:
	packages/accounts-ui-unstyled/login_buttons.js
2012-10-05 14:15:59 -07:00
Avital Oliver
1c9d4a7492 accounts-ui: support changing password, and some misc reorg
- If you're using accounts-password, or you are using more than one oauth provider,
  show a dropdown instead of the logout button. (This means that loginButtons either always
  shows a dropdown or never)
- If you have a username or email set, show "Change password" and "Logout" in the dropdown.
- If you don't have a username or email set, just show "Logout"

While at it, refactored some code I touched.
2012-10-05 12:30:27 -07:00
David Glasser
750629c718 livedata_connection_tests now create connections which don't prevent reload when
they have outstanding methods.
2012-10-05 11:17:12 -07:00
David Glasser
a49685a1ec Remove "fail" from a test name (to make it easier to find failures). 2012-10-05 01:12:55 -07:00
David Glasser
36f55a55b6 (Take 2.) In _validatedUpdate, make sure that the docs we're updating *still* match the selector.
Also, no need to call validators if no docs match the update or remove selector.
2012-10-05 01:08:03 -07:00
Avital Oliver
92b0036cf1 Merge pull request #356 from bradens/auth
Introduces the `accounts-github` package
2012-10-05 00:27:47 -07:00
Avital Oliver
c086ca0912 accounts-github: cleanup, small tweaks 2012-10-05 00:22:09 -07:00
Avital Oliver
a0049073a8 accounts-weibo: small clarification in configuration steps 2012-10-04 23:52:19 -07:00
Nick Martin
a1c93b6043 Change URLs to use / instead of ?. It looks much nicer. 2012-10-04 23:51:31 -07:00
Nick Martin
f36fc90c07 Add clear button to template demo. Fixes #362 2012-10-04 22:02:24 -07:00
Avital Oliver
f6e15a5dd7 Revert "In _validatedUpdate, make sure that the docs we're updating *still* match the"
This reverts commit 5e754e93a9.
2012-10-04 19:57:39 -07:00
David Glasser
7a25d86dc0 Update the docs for the removed callback to Cursor.observe. 2012-10-04 18:28:12 -07:00
David Glasser
5e754e93a9 In _validatedUpdate, make sure that the docs we're updating *still* match the
original selector.
2012-10-04 14:36:30 -07:00
David Glasser
afcafe1eb5 Refactor Mongo cursor reading so that all reads go through _nextObject. 2012-10-04 14:08:13 -07:00
David Glasser
57c3c2a50d _diffQuery: don't compare docs if there's no changed observer. 2012-10-04 14:05:06 -07:00