Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into rsgowman/link_by_fe…
…derated_id
  • Loading branch information
rsgowman committed Dec 22, 2020
commit fe882728640527cb9ecfcca5b44840f3906eda7c
18 changes: 18 additions & 0 deletions src/auth/auth-api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,24 @@ function validateCreateEditRequest(request: any, writeOperationType: WriteOperat
if (typeof request.linkProviderUserInfo !== 'undefined') {
validateProviderUserInfo(request.linkProviderUserInfo);
}

// mfaInfo is used for importUsers.
// mfa.enrollments is used for setAccountInfo.
// enrollments has to be an array of valid AuthFactorInfo requests.
let enrollments: AuthFactorInfo[] | null = null;
if (request.mfaInfo) {
enrollments = request.mfaInfo;
} else if (request.mfa && request.mfa.enrollments) {
enrollments = request.mfa.enrollments;
}
if (enrollments) {
if (!validator.isArray(enrollments)) {
throw new FirebaseAuthError(AuthClientErrorCode.INVALID_ENROLLED_FACTORS);
}
enrollments.forEach((authFactorInfoEntry: AuthFactorInfo) => {
validateAuthFactorInfo(authFactorInfoEntry, writeOperationType);
});
}
}


Expand Down
6 changes: 2 additions & 4 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
* limitations under the License.
*/

import {deepCopy} from '../utils/deep-copy';
import {UserRecord, CreateRequest, UpdateRequest} from './user-record';
import {FirebaseApp} from '../firebase-app';
import {FirebaseTokenGenerator, cryptoSignerFromApp} from './token-generator';
import { deepCopy } from '../utils/deep-copy';
import { UserRecord } from './user-record';
import {
isUidIdentifier, isEmailIdentifier, isPhoneIdentifier, isProviderIdentifier,
} from './identifier';
Expand Down
56 changes: 56 additions & 0 deletions src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,42 @@ export namespace auth {
phoneNumber: string;
}

/**
* Represents a user identity provider that can be associated with a Firebase user.
*/
interface UserProvider {

/**
* The user identifier for the linked provider.
*/
uid?: string;

/**
* The display name for the linked provider.
*/
displayName?: string;

/**
* The email for the linked provider.
*/
email?: string;

/**
* The phone number for the linked provider.
*/
phoneNumber?: string;

/**
* The photo URL for the linked provider.
*/
photoURL?: string;

/**
* The linked provider ID (for example, "google.com" for the Google provider).
*/
providerId?: string;
}

/**
* Interface representing a user.
*/
Expand Down Expand Up @@ -384,6 +420,26 @@ export namespace auth {
* The user's updated multi-factor related properties.
*/
multiFactor?: MultiFactorUpdateSettings;

/**
* Links this user to the specified provider.
*
* Linking a provider to an existing user account does not invalidate the
* refresh token of that account. In other words, the existing account
* would continue to be able to access resources, despite not having used
* the newly linked provider to login. If you wish to force the user to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a verb or infinitive, this is two words: "log in"

* authenticate with this new provider, you need to (a) revoke their
* refresh token (see
* https://firebase.google.com/docs/auth/admin/manage-sessions#revoke_refresh_tokens),
* and (b) ensure no other authentication methods are present on this
* account.
*/
providerToLink?: UserProvider;

/**
* Unlinks this user from the specified providers.
*/
providersToDelete?: string[];
}

/**
Expand Down
52 changes: 6 additions & 46 deletions src/auth/user-record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,12 @@ function parseDate(time: any): string | null {
return null;
}

/** Parameters for update user operation */
export interface UpdateRequest {
disabled?: boolean;
displayName?: string | null;
email?: string;
emailVerified?: boolean;
password?: string;
phoneNumber?: string | null;
photoURL?: string | null;
providerToLink?: UserProvider;
providersToDelete?: string[];
export interface MultiFactorInfoResponse {
mfaEnrollmentId: string;
displayName?: string;
phoneInfo?: string;
enrolledAt?: string;
[key: string]: any;
}

export interface ProviderUserInfoResponse {
Expand Down Expand Up @@ -339,41 +334,6 @@ export class UserInfo implements UserInfoInterface {
}
}

/**
* Represents a user identity provider that can be associated with a Firebase user.
*/
interface UserProvider {
/**
* The user identifier for the linked provider.
*/
uid?: string;

/**
* The display name for the linked provider.
*/
displayName?: string;

/**
* The email for the linked provider.
*/
email?: string;

/**
* The phone number for the linked provider.
*/
phoneNumber?: string;

/**
* The photo URL for the linked provider.
*/
photoURL?: string;

/**
* The linked provider ID (for example, "google.com" for the Google provider).
*/
providerId?: string;
}

/**
* User record class that defines the Firebase user object populated from
* the Firebase Auth getAccountInfo response.
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.