katowulf/mockfirebase — pull request #42 by katowulf (2014-12-17 01:27:26+00:00)
Title: Upgrade auth to be compatible with Firebase 1.1.x

@bendrucker please review and merge
@jwngr please look this over if you have time

Authentication now works like this:
```
// create a mock ref
var ref = new MockFirebase();

// optionally, simulate calling an authentication method
ref.authWithOAuthRedirect('facebook', function(error, userData) {
console.log('auth completed', error, userData);
});

// optionally, establish an onAuth() listener
ref.onAuth(function(userData) { console.log(userData); });

// authenticate the user with any valid auth creds we want to establish
ref.changeAuthState({ uid: 'kato', provider: 'facebook', facebook: {...} });

// flush the queue, which will trigger callbacks registered with authWithOAuthRedirect() and onAuth()
ref.flush();
```

I've set up email/password methods (`createUser`, `changePassword`, `resetPassword`, and `removeUser`) work with actual credentials. So if you call createUser() you can then use any of the other methods against the email/password that were added and it will function exactly as regular auth.

An existing email/password account can also be fetched by calling `getEmailUser(email)`, which will return object containing the `uid` (auto-generated), the `email`, and the `password'.

All of the auth* methods are implemented. Calling the auth method doesn't actually do anything, unless failNext() was invoked for that method. Otherwise, it just sets up the callback listener to wait for the next `changeAuthState()` invocation.

The `changeAuthState` method takes an object (or null to log users out) that represents the new authentication state received from the server. Invoking this method updates the value retrieved by `getAuth` and notifies any listeners established with `onAuth`.