Skip to content

Commit

Permalink
Release v3.0 (#384)
Browse files Browse the repository at this point in the history
* - Deprecated signInSuccess callback.
- Refactored and replaced deprecated/removed methods for compatibility with firebase-js-sdk v5.0.0.

PiperOrigin-RevId: 195502634
Change-Id: I186cc5e9091c44a97c85dd73f75e130561f97128

* updated changelog and readme, bumped core sdk dependency to 5.0

* bump core sdk version in demo app
  • Loading branch information
wti806 authored and bojeil-google committed May 8, 2018
1 parent dc57287 commit cac4047
Show file tree
Hide file tree
Showing 27 changed files with 4,166 additions and 3,640 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ Localized versions of the widget are available through the CDN. To use a localiz
localized JS library instead of the default library:

```html
<script src="https://www.gstatic.com/firebasejs/ui/2.7.0/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/2.7.0/firebase-ui-auth.css" />
<script src="https://www.gstatic.com/firebasejs/ui/3.0.0/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/3.0.0/firebase-ui-auth.css" />
```

where `{LANGUAGE_CODE}` is replaced by the code of the language you want. For example, the French
version of the library is available at
`https://www.gstatic.com/firebasejs/ui/2.7.0/firebase-ui-auth__fr.js`. The list of available
`https://www.gstatic.com/firebasejs/ui/3.0.0/firebase-ui-auth__fr.js`. The list of available
languages and their respective language codes can be found at [LANGUAGES.md](LANGUAGES.md).

Right-to-left languages also require the right-to-left version of the stylesheet, available at
`https://www.gstatic.com/firebasejs/ui/2.7.0/firebase-ui-auth-rtl.css`, instead of the default
`https://www.gstatic.com/firebasejs/ui/3.0.0/firebase-ui-auth-rtl.css`, instead of the default
stylesheet. The supported right-to-left languages are Arabic (ar), Farsi (fa), and Hebrew (iw).

### Option 2: npm Module
Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deprecated - Deprecated signInSuccess callback.
fixed - Refactored and replaced deprecated/removed methods for compatibility with firebase-js-sdk v5.0.0.
2 changes: 1 addition & 1 deletion demo/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<title>FirebaseUI Auth Demo</title>
<link rel="manifest" href="manifest.json">
<script src="https://www.gstatic.com/firebasejs/live/4.8/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/live/5.0/firebase.js"></script>
<script src="config.js"></script>
<script src="common.js"></script>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
Expand Down
1 change: 1 addition & 0 deletions javascript/testing/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ FakeAuthClient.AuthAsyncMethod = {
'createUserAndRetrieveDataWithEmailAndPassword',
CREATE_USER_WITH_EMAIL_AND_PASSWORD: 'createUserWithEmailAndPassword',
FETCH_PROVIDERS_FOR_EMAIL: 'fetchProvidersForEmail',
FETCH_SIGN_IN_METHODS_FOR_EMAIL: 'fetchSignInMethodsForEmail',
GET_REDIRECT_RESULT: 'getRedirectResult',
SEND_PASSWORD_RESET_EMAIL: 'sendPasswordResetEmail',
SET_PERSISTENCE: 'setPersistence',
Expand Down
17 changes: 17 additions & 0 deletions javascript/utils/idp.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,23 @@ firebaseui.auth.idp.AuthProviders = {
};


/**
* Map of provider to sign in methods.
* @package {Object<string, Object<string, string>>}
*/
firebaseui.auth.idp.SignInMethods = {
'facebook.com': {'FACEBOOK_SIGN_IN_METHOD': 'facebook.com'},
'github.com': {'GITHUB_SIGN_IN_METHOD': 'github.com'},
'google.com': {'GOOGLE_SIGN_IN_METHOD': 'google.com'},
'password': {
'EMAIL_PASSWORD_SIGN_IN_METHOD': 'password',
'EMAIL_LINK_SIGN_IN_METHOD': 'emailLink'
},
'twitter.com': {'TWITTER_SIGN_IN_METHOD': 'twitter.com'},
'phone': {'PHONE_SIGN_IN_METHOD': 'phone'}
};


/**
* @param {string} providerId
* @return {firebase.auth.AuthProvider} The IdP.
Expand Down
25 changes: 22 additions & 3 deletions javascript/widgets/authui.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ firebaseui.auth.AuthUI = function(auth, opt_appId) {
this.currentUser_ = null;
/** @private {boolean} Whether initial external Auth state is ready. */
this.initialStateReady_ = false;
/** @private {boolean} Whether the deprecation warning has been shown. */
this.warningShown_ = false;
};


Expand Down Expand Up @@ -759,6 +761,7 @@ firebaseui.auth.AuthUI.prototype.updateConfig = function(name, value) {
// Check if instance is already destroyed.
this.checkIfDestroyed_();
this.config_.update(name, value);
this.checkForDeprecation_();
};


Expand All @@ -770,6 +773,22 @@ firebaseui.auth.AuthUI.prototype.setConfig = function(config) {
// Check if instance is already destroyed.
this.checkIfDestroyed_();
this.config_.setConfig(config);
this.checkForDeprecation_();
};


/**
* Checks for deprecated configs passed and logs any warnings when detected.
* @private
*/
firebaseui.auth.AuthUI.prototype.checkForDeprecation_ = function() {
if (!this.warningShown_ &&
this.getConfig().getSignInSuccessCallback()) {
var deprecateWarning = 'signInSuccess callback is deprecated. Please use ' +
'signInSuccessWithAuthResult callback instead.';
firebaseui.auth.log.warning(deprecateWarning);
this.warningShown_ = true;
}
};


Expand Down Expand Up @@ -882,7 +901,7 @@ firebaseui.auth.AuthUI.prototype.startSignInWithEmailAndPassword =
// flow, the same credential will be used to complete sign in on the
// external Auth instance.
return /** @type {!firebase.Promise<!firebase.auth.UserCredential>} */ (
this.getAuth().signInAndRetrieveDataWithEmailAndPassword(email, password)
this.getAuth().signInWithEmailAndPassword(email, password)
.then(function(result) {
var cb = function(user) {
if (user) {
Expand Down Expand Up @@ -932,7 +951,7 @@ firebaseui.auth.AuthUI.prototype.startCreateUserWithEmailAndPassword =
// Auth instance as finish sign in will sign in with that same credential
// to developer Auth instance.
return /** @type {!firebase.Promise<!firebase.auth.UserCredential>} */ (
self.getAuth().createUserAndRetrieveDataWithEmailAndPassword(
self.getAuth().createUserWithEmailAndPassword(
email, password));
}
};
Expand Down Expand Up @@ -1285,7 +1304,7 @@ firebaseui.auth.AuthUI.prototype.signInWithExistingEmailAndPasswordForLinking =
// Starts sign in with email/password on the internal Auth instance for
// linking purposes. This is needed to avoid triggering the onAuthStateChanged
// callbacks interrupting the linking flow.
return this.getAuth().signInAndRetrieveDataWithEmailAndPassword(
return this.getAuth().signInWithEmailAndPassword(
email, password);
};

Expand Down
101 changes: 89 additions & 12 deletions javascript/widgets/authui_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,10 @@ function assertConfigEquals(config, widgetConfig) {


function testConfig() {
testStubs.set(
firebaseui.auth.log,
'warning',
goog.testing.recordFunction());
createAndInstallTestInstances();
// Check configuration set correctly for each app.
assertConfigEquals(
Expand All @@ -883,10 +887,55 @@ function testConfig() {
assertConfigEquals(
config3,
app3.getConfig());
app1.setConfig(config1);
/** @suppress {missingRequire} */
assertEquals(0, firebaseui.auth.log.warning.getCallCount());
// Verifies that signInSuccess callback throws deprecation warning.
var callbacks = {
'signInSuccess': function(currentUser, credential, redirectUrl) {
return true;
}
};
app1.setConfig({
'callbacks': callbacks
});
assertConfigEquals(
{
'signInSuccessUrl': 'http://localhost/home1',
'widgetUrl': 'http://localhost/firebase1',
'callbacks': callbacks
},
app1.getConfig());
var deprecateWarning = 'signInSuccess callback is deprecated. Please use ' +
'signInSuccessWithAuthResult callback instead.';
/** @suppress {missingRequire} */
assertEquals(1, firebaseui.auth.log.warning.getCallCount());
/** @suppress {missingRequire} */
assertEquals(deprecateWarning,
firebaseui.auth.log.warning.getLastCall().getArgument(0));
app1.setConfig({
'callbacks': callbacks
});
// Deprecation warning should be only shown once.
/** @suppress {missingRequire} */
assertEquals(1, firebaseui.auth.log.warning.getCallCount());
// Verifies that warning is shown for new instance.
app2.setConfig({
'callbacks': callbacks
});
/** @suppress {missingRequire} */
assertEquals(2, firebaseui.auth.log.warning.getCallCount());
/** @suppress {missingRequire} */
assertEquals(deprecateWarning,
firebaseui.auth.log.warning.getLastCall().getArgument(0));
}


function testUpdateConfig() {
testStubs.set(
firebaseui.auth.log,
'warning',
goog.testing.recordFunction());
createAndInstallTestInstances();
// Original config.
var config = {
Expand Down Expand Up @@ -915,6 +964,34 @@ function testUpdateConfig() {
assertConfigEquals(
expectedConfig,
app1.getConfig());
/** @suppress {missingRequire} */
assertEquals(0, firebaseui.auth.log.warning.getCallCount());
// Verifies that signInSuccess callback throws deprecation warning.
var callbacks = {
'signInSuccess': function(currentUser, credential, redirectUrl) {
return true;
}
};
app1.updateConfig('callbacks', callbacks);
assertConfigEquals(
{
'signInSuccessUrl': 'http://localhost/home1',
'widgetUrl': 'http://localhost/firebase1',
'siteName': 'Other_Site_Name',
'callbacks': callbacks
},
app1.getConfig());
var deprecateWarning = 'signInSuccess callback is deprecated. Please use ' +
'signInSuccessWithAuthResult callback instead.';
/** @suppress {missingRequire} */
assertEquals(1, firebaseui.auth.log.warning.getCallCount());
/** @suppress {missingRequire} */
assertEquals(deprecateWarning,
firebaseui.auth.log.warning.getLastCall().getArgument(0));
// Deprecation warning should be only shown once.
app1.updateConfig('callbacks', callbacks);
/** @suppress {missingRequire} */
assertEquals(1, firebaseui.auth.log.warning.getCallCount());
}


Expand Down Expand Up @@ -1350,7 +1427,7 @@ function testStartSignInWithEmailAndPassword_success() {
assertObjectEquals(expectedUserCredential, userCredential);
asyncTestCase.signal();
});
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertSignInWithEmailAndPassword(
['[email protected]', 'password'],
function() {
app.getAuth().setUser(expectedUser);
Expand Down Expand Up @@ -1380,7 +1457,7 @@ function testStartSignInWithEmailAndPassword_error() {
assertEquals(expectedError, error);
asyncTestCase.signal();
});
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertSignInWithEmailAndPassword(
['[email protected]', 'password'],
null,
expectedError);
Expand Down Expand Up @@ -1427,7 +1504,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_isAnonymous_success() {
});
// Simulate anonymous user logged in on external instance.
testAuth.setUser(anonymousUser);
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertSignInWithEmailAndPassword(
['[email protected]', 'password'],
function() {
app.getAuth().setUser(expectedUser);
Expand Down Expand Up @@ -1480,7 +1557,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_isAnon_error() {
asyncTestCase.signal();
});
// Simulate wrong password error on sign-in.
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertSignInWithEmailAndPassword(
['[email protected]', 'password'],
null,
expectedError);
Expand Down Expand Up @@ -1511,7 +1588,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_nonAnon_success() {
assertObjectEquals(expectedUserCredential, userCredential);
asyncTestCase.signal();
});
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertSignInWithEmailAndPassword(
['[email protected]', 'password'],
function() {
app.getAuth().setUser(expectedUser);
Expand Down Expand Up @@ -1551,7 +1628,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnonymous_noUser_success() {
assertObjectEquals(expectedUserCredential, userCredential);
asyncTestCase.signal();
});
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertSignInWithEmailAndPassword(
['[email protected]', 'password'],
function() {
app.getAuth().setUser(expectedUser);
Expand Down Expand Up @@ -1587,7 +1664,7 @@ function testStartCreateUserWithEmailAndPassword_success() {
assertObjectEquals(expectedUserCredential, userCredential);
asyncTestCase.signal();
});
app.getAuth().assertCreateUserAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertCreateUserWithEmailAndPassword(
['[email protected]', 'password'],
function() {
app.getAuth().setUser(expectedUser);
Expand Down Expand Up @@ -1617,7 +1694,7 @@ function testStartCreateUserWithEmailAndPassword_error() {
assertEquals(expectedError, error);
asyncTestCase.signal();
});
app.getAuth().assertCreateUserAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertCreateUserWithEmailAndPassword(
['[email protected]', 'password'],
null,
expectedError);
Expand Down Expand Up @@ -1694,7 +1771,7 @@ function testStartCreateUserWithEmailAndPassword__upgradeAnon_noUser_success() {
app.getExternalAuth().runAuthChangeHandler();
// createUserWithEmailAndPassword called on internal Auth instance as no user
// available.
app.getAuth().assertCreateUserAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertCreateUserWithEmailAndPassword(
['[email protected]', 'password'],
function() {
app.getAuth().setUser(expectedUser);
Expand Down Expand Up @@ -1780,7 +1857,7 @@ function testStartCreateUserWithEmailAndPassword_upgradeAnon_nonAnon_success() {
});
// Trigger initial onAuthStateChanged listener.
app.getExternalAuth().runAuthChangeHandler();
app.getAuth().assertCreateUserAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertCreateUserWithEmailAndPassword(
['[email protected]', 'password'],
function() {
app.getAuth().setUser(expectedUser);
Expand Down Expand Up @@ -3812,7 +3889,7 @@ function testSignInWithExistingEmailAndPasswordForLinking_success() {
assertObjectEquals(expectedUserCredential, userCredential);
asyncTestCase.signal();
});
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertSignInWithEmailAndPassword(
['[email protected]', 'password'],
function() {
app.getAuth().setUser(expectedUser);
Expand Down Expand Up @@ -3843,7 +3920,7 @@ function testSignInWithExistingEmailAndPasswordForLinking_error() {
assertEquals(expectedError, error);
asyncTestCase.signal();
});
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
app.getAuth().assertSignInWithEmailAndPassword(
['[email protected]', 'password'],
null,
expectedError);
Expand Down
Loading

0 comments on commit cac4047

Please sign in to comment.