Skip to content

Auth deprecation #1726

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 5 commits into from
May 1, 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
19 changes: 5 additions & 14 deletions packages/auth-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface User extends UserInfo {
linkAndRetrieveDataWithCredential(
credential: AuthCredential
): Promise<UserCredential>;
linkWithCredential(credential: AuthCredential): Promise<User>;
linkWithCredential(credential: AuthCredential): Promise<UserCredential>;
linkWithPhoneNumber(
phoneNumber: string,
applicationVerifier: ApplicationVerifier
Expand All @@ -40,7 +40,9 @@ export interface User extends UserInfo {
reauthenticateAndRetrieveDataWithCredential(
credential: AuthCredential
): Promise<UserCredential>;
reauthenticateWithCredential(credential: AuthCredential): Promise<void>;
reauthenticateWithCredential(
credential: AuthCredential
): Promise<UserCredential>;
reauthenticateWithPhoneNumber(
phoneNumber: string,
applicationVerifier: ApplicationVerifier
Expand Down Expand Up @@ -277,12 +279,7 @@ export class FirebaseAuth {
email: string,
password: string
): Promise<UserCredential>;
createUserAndRetrieveDataWithEmailAndPassword(
email: string,
password: string
): Promise<UserCredential>;
currentUser: User | null;
fetchProvidersForEmail(email: string): Promise<Array<string>>;
fetchSignInMethodsForEmail(email: string): Promise<Array<string>>;
isSignInWithEmailLink(emailLink: string): boolean;
getRedirectResult(): Promise<UserCredential>;
Expand Down Expand Up @@ -311,18 +308,12 @@ export class FirebaseAuth {
credential: AuthCredential
): Promise<UserCredential>;
signInAnonymously(): Promise<UserCredential>;
signInAnonymouslyAndRetrieveData(): Promise<UserCredential>;
signInWithCredential(credential: AuthCredential): Promise<User>;
signInWithCredential(credential: AuthCredential): Promise<UserCredential>;
signInWithCustomToken(token: string): Promise<UserCredential>;
signInAndRetrieveDataWithCustomToken(token: string): Promise<UserCredential>;
signInWithEmailAndPassword(
email: string,
password: string
): Promise<UserCredential>;
signInAndRetrieveDataWithEmailAndPassword(
email: string,
password: string
): Promise<UserCredential>;
signInWithEmailLink(
email: string,
emailLink?: string
Expand Down
110 changes: 16 additions & 94 deletions packages/auth/src/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -1432,36 +1432,6 @@ fireauth.Auth.prototype.signInWithCustomToken = function(token) {
};


/**
* Signs in a user asynchronously using a custom token and returns any
* additional user info data or credentials returned form the backend. It has
* been deprecated in favor of signInWithCustomToken.
* @param {string} token The custom token to sign in with.
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.Auth.prototype.signInAndRetrieveDataWithCustomToken = function(token) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.SIGN_IN_WITH_CUSTOM_TOKEN);
return this.signInWithCustomToken(token);
};


/**
* Sign in using an email and password and returns any additional user info
* data or credentials returned form the backend. It has been deprecated in
* favor of signInWithEmailAndPassword.
* @param {string} email The email to sign in with.
* @param {string} password The password to sign in with.
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.Auth.prototype.signInAndRetrieveDataWithEmailAndPassword =
function(email, password) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.SIGN_IN_WITH_EMAIL_AND_PASSWORD);
return this.signInWithEmailAndPassword(email, password);
};


/**
* Sign in using an email and password and returns any additional user info
* data or credentials returned form the backend.
Expand Down Expand Up @@ -1502,47 +1472,13 @@ fireauth.Auth.prototype.createUserWithEmailAndPassword =
};


/**
* Creates a new email and password account and returns any additional user
* info data or credentials returned form the backend. It has been deprecated
* in favor of createUserWithEmailAndPassword.
* @param {string} email The email to sign up with.
* @param {string} password The password to sign up with.
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.Auth.prototype.createUserAndRetrieveDataWithEmailAndPassword =
function(email, password) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.CREATE_USER_WITH_EMAIL_AND_PASSWORD);
return this.createUserWithEmailAndPassword(email, password);
};


/**
* Logs into Firebase with the given 3rd party credentials. It has been
* deprecated in favor of signInAndRetrieveDataWithCredential.
* @param {!fireauth.AuthCredential} credential The auth credential.
* @return {!goog.Promise<!fireauth.AuthUser>}
*/
fireauth.Auth.prototype.signInWithCredential = function(credential) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.SIGN_IN_WITH_CREDENTIAL);
// Get signInAndRetrieveDataWithCredential result and return the user only.
return this.signInAndRetrieveDataWithCredential(credential)
.then(function(result) {
return result['user'];
});
};


/**
* Logs into Firebase with the given 3rd party credentials and returns any
* additional user info data or credentials returned form the backend.
* @param {!fireauth.AuthCredential} credential The Auth credential.
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.Auth.prototype.signInAndRetrieveDataWithCredential =
function(credential) {
fireauth.Auth.prototype.signInWithCredential = function(credential) {
// Credential could be extended in the future, so leave it to credential to
// decide how to retrieve ID token.
var self = this;
Expand All @@ -1557,6 +1493,21 @@ fireauth.Auth.prototype.signInAndRetrieveDataWithCredential =
};


/**
* Logs into Firebase with the given 3rd party credentials and returns any
* additional user info data or credentials returned form the backend. It has
* been deprecated in favor of signInWithCredential.
* @param {!fireauth.AuthCredential} credential The Auth credential.
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.Auth.prototype.signInAndRetrieveDataWithCredential =
function(credential) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.SIGN_IN_WITH_CREDENTIAL);
return this.signInWithCredential(credential);
};


/**
* Signs in a user anonymously and returns any additional user info data or
* credentials returned form the backend.
Expand Down Expand Up @@ -1607,19 +1558,6 @@ fireauth.Auth.prototype.signInAnonymously = function() {
};


/**
* Signs in a user anonymously and returns any additional user info data or
* credentials returned form the backend. It has been deprecated in favor of
* signInWithAnonymously.
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.Auth.prototype.signInAnonymouslyAndRetrieveData = function() {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.SIGN_IN_ANONYMOUSLY);
return this.signInAnonymously();
};


/**
* @return {string} The key used for storing Auth state.
*/
Expand Down Expand Up @@ -1866,22 +1804,6 @@ fireauth.Auth.prototype.registerPendingPromise_ = function(p) {
};


/**
* Gets the list of IDPs that can be used to log in for the given email address.
* It has been deprecated in favor of fetchSignInMethodsForEmail.
* @param {string} email The email address.
* @return {!goog.Promise<!Array<!fireauth.idp.ProviderId>>}
*/
fireauth.Auth.prototype.fetchProvidersForEmail = function(email) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.FETCH_PROVIDERS_FOR_EMAIL);
return /** @type {!goog.Promise<!Array<!fireauth.idp.ProviderId>>} */ (
this.registerPendingPromise_(
this.getRpcHandler().fetchProvidersForIdentifier(email)
));
};


/**
* Gets the list of possible sign in methods for the given email address.
* @param {string} email The email address.
Expand Down
76 changes: 35 additions & 41 deletions packages/auth/src/authuser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,28 @@ fireauth.AuthUser.prototype.extractLinkedAccounts_ = function(resp) {
* Reauthenticates a user using a fresh credential, to be used before operations
* such as updatePassword that require tokens from recent login attempts. It
* also returns any additional user info data or credentials returned form the
* backend.
* backend. It has been deprecated in favor of reauthenticateWithCredential.
* @param {!fireauth.AuthCredential} credential
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.AuthUser.prototype.reauthenticateAndRetrieveDataWithCredential =
function(credential) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.REAUTH_WITH_CREDENTIAL);
return this.reauthenticateWithCredential(credential);
};


/**
* Reauthenticates a user using a fresh credential, to be used before operations
* such as updatePassword that require tokens from recent login attempts. It
* also returns any additional user info data or credentials returned form the
* backend.
* @param {!fireauth.AuthCredential} credential
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.AuthUser.prototype.reauthenticateWithCredential =
function(credential) {
var self = this;
var userCredential = null;
// Register this pending promise but bypass user invalidation check.
Expand Down Expand Up @@ -1158,25 +1174,6 @@ fireauth.AuthUser.prototype.reauthenticateAndRetrieveDataWithCredential =
};


/**
* Reauthenticates a user using a fresh credential, to be used before operations
* such as updatePassword that require tokens from recent login attempts. It has
* been deprecated in favor of reauthenticateAndRetrieveDataWithCredential.
* @param {!fireauth.AuthCredential} credential
* @return {!goog.Promise<void>}
*/
fireauth.AuthUser.prototype.reauthenticateWithCredential =
function(credential) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.REAUTH_WITH_CREDENTIAL);
// Get reauthenticateAndRetrieveDataWithCredential result and return void.
return this.reauthenticateAndRetrieveDataWithCredential(credential)
.then(function(result) {
// Do not return anything. Promise should resolve with void.
});
};


/**
* Reloads the user and then checks if a provider is already linked. If so,
* this returns a Promise that rejects. Note that state change listeners are not
Expand Down Expand Up @@ -1205,13 +1202,28 @@ fireauth.AuthUser.prototype.checkIfAlreadyLinked_ =

/**
* Links a provider to the current user and returns any additional user info
* data or credentials returned form the backend.
* data or credentials returned form the backend. It has been deprecated in
* favor of linkWithCredential.
* @param {!fireauth.AuthCredential} credential The credential from the Auth
* provider.
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.AuthUser.prototype.linkAndRetrieveDataWithCredential =
function(credential) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.LINK_WITH_CREDENTIAL);
return this.linkWithCredential(credential);
};


/**
* Links a provider to the current user and returns any additional user info
* data or credentials returned form the backend.
* @param {!fireauth.AuthCredential} credential The credential from the Auth
* provider.
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
*/
fireauth.AuthUser.prototype.linkWithCredential = function(credential) {
var self = this;
var userCredential = null;
// Register this pending promise. This will also check for user invalidation.
Expand All @@ -1238,24 +1250,6 @@ fireauth.AuthUser.prototype.linkAndRetrieveDataWithCredential =
};


/**
* Links a provider to the current user. It has been deprecated in favor of
* linkAndRetrieveDataWithCredential.
* @param {!fireauth.AuthCredential} credential The credential from the Auth
* provider.
* @return {!goog.Promise<!fireauth.AuthUser>}
*/
fireauth.AuthUser.prototype.linkWithCredential = function(credential) {
fireauth.deprecation.log(
fireauth.deprecation.Deprecations.LINK_WITH_CREDENTIAL);
// Get linkAndRetrieveDataWithCredential result and return the user only.
return this.linkAndRetrieveDataWithCredential(credential)
.then(function(result) {
return result['user'];
});
};


/**
* Links a phone number using the App verifier instance and returns a
* promise that resolves with the confirmation result which on confirmation
Expand All @@ -1280,7 +1274,7 @@ fireauth.AuthUser.prototype.linkWithPhoneNumber =
phoneNumber,
appVerifier,
// This will check again if the credential is linked.
goog.bind(self.linkAndRetrieveDataWithCredential, self));
goog.bind(self.linkWithCredential, self));
})));
};

Expand All @@ -1307,7 +1301,7 @@ fireauth.AuthUser.prototype.reauthenticateWithPhoneNumber =
self.getAuth_(),
phoneNumber,
appVerifier,
goog.bind(self.reauthenticateAndRetrieveDataWithCredential,
goog.bind(self.reauthenticateWithCredential,
self));
}),
// Skip invalidation check as reauthentication could revalidate a
Expand Down
31 changes: 8 additions & 23 deletions packages/auth/src/deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,15 @@ goog.require('fireauth.util');
* @enum {string}
*/
fireauth.deprecation.Deprecations = {
CREATE_USER_WITH_EMAIL_AND_PASSWORD: 'firebase.auth.Auth.prototype.createUs' +
'erAndRetrieveDataWithEmailAndPassword is deprecated. Please use fireba' +
'se.auth.Auth.prototype.createUserWithEmailAndPassword instead.',
FETCH_PROVIDERS_FOR_EMAIL: 'firebase.auth.Auth.prototype.fetchProvidersForE' +
'mail is deprecated. Please use firebase.auth.Auth.prototype.fetchSignI' +
'nMethodsForEmail instead.',
LINK_WITH_CREDENTIAL: 'firebase.User.prototype.linkWithCredential is deprec' +
'ated. Please use firebase.User.prototype.linkAndRetrieveDataWithCreden' +
LINK_WITH_CREDENTIAL: 'firebase.User.prototype.linkAndRetrieveDataWithCrede' +
'ntial is deprecated. Please use firebase.User.prototype.linkWithCreden' +
'tial instead.',
REAUTH_WITH_CREDENTIAL: 'firebase.User.prototype.reauthenticateWithCredenti' +
'al is deprecated. Please use firebase.User.prototype.reauthenticateAnd' +
'RetrieveDataWithCredential instead.',
SIGN_IN_ANONYMOUSLY: 'firebase.auth.Auth.prototype.signInAnonymouslyAndRetr' +
'ieveData is deprecated. Please use firebase.auth.Auth.prototype.signIn' +
'Anonymously instead.',
SIGN_IN_WITH_CREDENTIAL: 'firebase.auth.Auth.prototype.signInWithCredential' +
' is deprecated. Please use firebase.auth.Auth.prototype.signInAndRetri' +
'eveDataWithCredential instead.',
SIGN_IN_WITH_CUSTOM_TOKEN: 'firebase.auth.Auth.prototype.signInAndRetrieveD' +
'ataWithCustomToken is deprecated. Please use firebase.auth.Auth.protot' +
'ype.signInWithCustomToken instead.',
SIGN_IN_WITH_EMAIL_AND_PASSWORD: 'firebase.auth.Auth.prototype.signInAndRet' +
'rieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.' +
'Auth.prototype.signInWithEmailAndPassword instead.'
REAUTH_WITH_CREDENTIAL: 'firebase.User.prototype.reauthenticateAndRetrieveD' +
'ataWithCredential is deprecated. Please use firebase.User.prototype.re' +
'authenticateWithCredential instead.',
SIGN_IN_WITH_CREDENTIAL: 'firebase.auth.Auth.prototype.signInAndRetrieveDat' +
'aWithCredential is deprecated. Please use firebase.auth.Auth.prototype' +
'.signInWithCredential instead.'
};


Expand Down
Loading