Commit Graph

1769 Commits

Author SHA1 Message Date
David Glasser
bbf9ae0c2b Fix Mongo write error handling.
Previously, if we did a Mongo write inside a method and Mongo returned an error
(eg, duplicate key in a unique index), the write fence would never fire and the
client would never quiesce. Now we make sure to fire the write fence (and mark
the collection dirty) even on error.
2012-10-09 23:12:16 -07:00
Nick Martin
5fd3c7ce71 Re-rename 'confirm' to 'verify'. 2012-10-09 22:44:25 -07:00
Nick Martin
5c8c22c9c7 Accounts.createUser on server no longer sends enrollment email. sendXXXEmail functions now have email as an optional argument. 2012-10-09 22:44:25 -07:00
Nick Martin
1311f9d8cc Missing var. 2012-10-09 22:44:24 -07:00
Avital Oliver
002768d72a accounts-ui: Validate username/email on login
This resolves a strange error you get if you sign in with all fields empty
2012-10-09 22:28:31 -07:00
Avital Oliver
a6e71dcde6 accounts-github: better dimensions for popup 2012-10-09 22:14:03 -07:00
Avital Oliver
7757cc0659 accounts-ui: dropdown opens by default to right, unless wrapped in an element with class 2012-10-09 21:52:52 -07:00
Avital Oliver
168be9f059 accounts-ui: default to EMAIL_ONLY 2012-10-09 21:14:47 -07:00
Avital Oliver
b5aa098c89 Minor fix to an older commit 2012-10-09 20:25:29 -07:00
Avital Oliver
4cc5be00c0 Add null support for options in Meteor.loginWithTwitter and Meteor.loginWithWeibo 2012-10-09 20:23:39 -07:00
Avital Oliver
c5044e57cd Allow multiple calls to Accounts.config without overriding settings 2012-10-09 20:18:19 -07:00
Avital Oliver
cbf06a5679 Rename forbidSignups -> forbidClientAccountCreation 2012-10-09 20:13:59 -07:00
Avital Oliver
df622401b4 accounts-ui: redo Accounts.ui.config 2012-10-09 20:11:15 -07:00
Avital Oliver
7d368a3f6e accounts-ui: configure scope for external services 2012-10-09 20:04:19 -07:00
Nick Martin
accd41bddf Remove Accounts.{facebook,github,google}.config. Replace with options in loginWithFacebook. 2012-10-09 20:04:19 -07:00
Avital Oliver
14f975ea30 accounts: introduce accounts-ui configuration, simplify accounts configuration
We no longer pass the requireEmail and requireUserame options in
Accounts.config (which means we also don't validate new users when
they are created -- that should probably be done with a server
analogue of .allow())

Instead, Accounts.ui.config can be passed a newUserWithPasswordHas
option with four distinct UI configurations.
2012-10-09 20:02:52 -07:00
David Glasser
dd77a26acc Rename Accounts.configuration to Accounts.loginServiceConfiguration.
Matches other references to it in the code, and is harder to confuse with
Accounts.config.
2012-10-09 19:18:02 -07:00
David Glasser
78779f3ca4 Don't allow clients to set fields in the createUser method that they can't later
modify with the default Meteor.users update allow rule.

This does mean that it's difficult for trusted server code calling
Accounts.createUser, even with a custom onCreateUser hook, to set values on the
new user that can't also be set by arbitrary clients. For now, server code
needing to do this can just set it with a post-create update; later we might add
another parameter to onCreateUser.
2012-10-09 18:52:15 -07:00
David Greenspan
a61b24bd1c auth dialog CSS includes reset, more resilient 2012-10-09 17:23:51 -07:00
David Glasser
ff359a73c6 Make sure that the client doesn't get confused by an unsub followed immediately
by an identical sub.

Previously, it would fail to subscribe. This confused the meteor.currentUser
subscription in accounts_client.js. Reproduction:

  - Create user X with email (which sends a confirmation email)
  - Log out.
  - Log in as User Y in tab 1.
  - Follow the confirmation link in tab 2. This leaves you logged in
    as User Y.
  - Tab 1's localstorage poller notices that there's a new token and logs in
    with it.
  - After a successful login, Accounts._makeClientLoggedIn unsubs from
    meteor.currentUser and immediately resubs. It thinks there's already an
    existing sub, so it doesn't send the sub message and does immediately call
    the ready callback (which sets userLoaded() to true).
  - The unsub gets sent and the object in Meteor.users() gets depopulated.

Now Meteor.userLoaded() is true but Meteor.user() is empty.
2012-10-09 17:02:01 -07:00
David Greenspan
205a491b5d use CSS star hack 2012-10-09 16:26:10 -07:00
Nick Martin
fbdf164251 Rename email 'validation' to 'confirmation'. 2012-10-09 16:12:45 -07:00
David Greenspan
649b4f5154 give login-buttons DIV display: inline-block 2012-10-09 16:05:56 -07:00
David Greenspan
cd55add975 dialog drop-shadow tweaks 2012-10-09 16:05:12 -07:00
David Glasser
9e09d64831 Prefix all accounts-ui templates other than loginButtons with an underscore.
In the future we may support use of some of the sub-templates directly (eg, we
might expose a "sign in" template and a "create user" template, and keep the
events and links for switching between them on the outer loginButtons) but we
don't yet. This change leaves us open to change the internal details later.
2012-10-09 12:00:25 -07:00
David Glasser
dffed84155 Make Meteor.user() reactive on user-loaded state. Fix #380. 2012-10-09 11:18:03 -07:00
Lloyd Brookes
ae46f89bc2 replaced 'currentInvocation.userId()' with 'currentInvocation.userId' 2012-10-09 15:41:17 +01:00
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