Skip to content

updated demo to remove deprecated APIs #1755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions packages/auth/demo/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,15 @@
Confirm Password Change
</button>
</form>
<!-- Fetch Sign In Methods/Providers -->
<div class="group">Fetch Sign In Methods/Providers</div>
<!-- Fetch Sign In Methods -->
<div class="group">Fetch Sign In Methods</div>
<form class="form form-bordered no-submit">
<input type="email" name="email" id="fetch-providers-email"
<input type="email" name="email" id="fetch-sign-in-methods-email"
class="form-control" placeholder="Email" />
<button class="btn btn-block btn-primary"
id="fetch-sign-in-methods-for-email">
Fetch Sign In Methods For Email
</button>
<button class="btn btn-block btn-primary"
id="fetch-providers-for-email">
Fetch Providers For Email
</button>
</form>

<!-- Update Current User -->
Expand Down
36 changes: 9 additions & 27 deletions packages/auth/demo/public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function onLinkWithEmailLink() {
var link = $('#link-with-email-link-link').val() || undefined;
var credential = firebase.auth.EmailAuthProvider
.credentialWithLink(email, link);
activeUser().linkAndRetrieveDataWithCredential(credential)
activeUser().linkWithCredential(credential)
.then(onAuthUserCredentialSuccess, onAuthError);
}

Expand All @@ -357,7 +357,7 @@ function onReauthenticateWithEmailLink() {
var link = $('#link-with-email-link-link').val() || undefined;
var credential = firebase.auth.EmailAuthProvider
.credentialWithLink(email, link);
activeUser().reauthenticateAndRetrieveDataWithCredential(credential)
activeUser().reauthenticateWithCredential(credential)
.then(function(result) {
logAdditionalUserInfo(result);
refreshUserData();
Expand Down Expand Up @@ -396,7 +396,7 @@ function onSignInWithGenericIdPCredential() {
var idToken = $('#signin-generic-idp-id-token').val();
var accessToken = $('#signin-generic-idp-access-token').val();
var provider = new firebase.auth.OAuthProvider(providerId);
auth.signInAndRetrieveDataWithCredential(
auth.signInWithCredential(
provider.credential(idToken, accessToken))
.then(onAuthUserCredentialSuccess, onAuthError);
}
Expand Down Expand Up @@ -525,7 +525,7 @@ function onReauthConfirmPhoneVerification() {
var verificationCode = $('#link-reauth-phone-verification-code').val();
var credential = firebase.auth.PhoneAuthProvider.credential(
verificationId, verificationCode);
activeUser().reauthenticateAndRetrieveDataWithCredential(credential)
activeUser().reauthenticateWithCredential(credential)
.then(function(result) {
logAdditionalUserInfo(result);
refreshUserData();
Expand All @@ -544,14 +544,14 @@ function signInOrLinkCredential(credential) {
alertError('You need to sign in before linking an account.');
return;
}
activeUser().linkAndRetrieveDataWithCredential(credential)
activeUser().linkWithCredential(credential)
.then(function(result) {
logAdditionalUserInfo(result);
refreshUserData();
alertSuccess('Provider linked!');
}, onAuthError);
} else {
auth.signInAndRetrieveDataWithCredential(credential)
auth.signInWithCredential(credential)
.then(onAuthUserCredentialSuccess, onAuthError);
}
}
Expand Down Expand Up @@ -715,28 +715,11 @@ function onConfirmPasswordReset() {
}


/**
* Gets the list of IDPs that can be used to log in for the given email address.
*/
function onFetchProvidersForEmail() {
var email = $('#fetch-providers-email').val();
auth.fetchProvidersForEmail(email).then(function(providers) {
log('Providers for ' + email + ' :');
log(providers);
if (providers.length == 0) {
alertSuccess('Providers for ' + email + ': N/A');
} else {
alertSuccess('Providers for ' + email +': ' + providers.join(', '));
}
}, onAuthError);
}


/**
* Gets the list of possible sign in methods for the given email address.
*/
function onFetchSignInMethodsForEmail() {
var email = $('#fetch-providers-email').val();
var email = $('#fetch-sign-in-methods-email').val();
auth.fetchSignInMethodsForEmail(email).then(function(signInMethods) {
log('Sign in methods for ' + email + ' :');
log(signInMethods);
Expand Down Expand Up @@ -765,7 +748,7 @@ function onGetProviderData() {
function onLinkWithEmailAndPassword() {
var email = $('#link-email').val();
var password = $('#link-password').val();
activeUser().linkAndRetrieveDataWithCredential(
activeUser().linkWithCredential(
firebase.auth.EmailAuthProvider.credential(email, password))
.then(onAuthUserCredentialSuccess, onAuthError);
}
Expand All @@ -779,7 +762,7 @@ function onLinkWithGenericIdPCredential() {
var idToken = $('#link-generic-idp-id-token').val();
var accessToken = $('#link-generic-idp-access-token').val();
var provider = new firebase.auth.OAuthProvider(providerId);
activeUser().linkAndRetrieveDataWithCredential(
activeUser().linkWithCredential(
provider.credential(idToken, accessToken))
.then(onAuthUserCredentialSuccess, onAuthError);
}
Expand Down Expand Up @@ -1500,7 +1483,6 @@ function initApp(){
$('#set-language-code').click(onSetLanguageCode);
$('#use-device-language').click(onUseDeviceLanguage);

$('#fetch-providers-for-email').click(onFetchProvidersForEmail);
$('#fetch-sign-in-methods-for-email').click(onFetchSignInMethodsForEmail);

$('#run-web-worker-tests').click(onRunWebWorkTests);
Expand Down
4 changes: 2 additions & 2 deletions packages/auth/demo/public/web-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ var runWorkerTests = function(googleIdToken) {
});
})
.then(function() {
return firebase.auth().signInAndRetrieveDataWithCredential(
return firebase.auth().signInWithCredential(
oauthCredential);
})
.then(function(result) {
Expand All @@ -152,7 +152,7 @@ var runWorkerTests = function(googleIdToken) {
!result.credential ||
!result.additionalUserInfo) {
throw new Error(
'signInAndRetrieveDataWithCredential unexpectedly failed!');
'signInWithCredential unexpectedly failed!');
}
return firebase.auth().signOut();
})
Expand Down