Skip to content

Add in disable_user to auth calls #8462

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

Closed
wants to merge 3 commits into from
Closed
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
44 changes: 44 additions & 0 deletions src/gcp/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ import { identityOrigin } from "../api";

const apiClient = new Client({ urlPrefix: identityOrigin(), auth: true });

interface ProviderUserInfo {
providerId: string;
displayName: string;
photoUrl: string;
federatedId: string;
email: string;
rawId: string;
screenName: string;
phoneNumber: string;
}

interface SetAccountInfoResponse {
localId: string;
idToken: string;
providerUserInfo: ProviderUserInfo[];
newEmail: string;
refreshToken: string;
expiresIn: string;
emailVerified: boolean;
}

/**
* Returns the list of authorized domains.
* @param project project identifier.
Expand Down Expand Up @@ -36,3 +57,26 @@ export async function updateAuthDomains(project: string, authDomains: string[]):
);
return res.body.authorizedDomains;
}

/**
* Disables or enabled a user from a particular project.
* @param project project identifier.
* @param uid the user id of the user from the firebase project.
* @param disabled sets whether the user is marked as disabled (true) or enabled (false).
* @return the call succeeded (true).
*/
export async function disableUser(
project: string,
uid: string,
disabled: boolean,
): Promise<boolean> {
const res = await apiClient.post<
{ disableUser: boolean; targetProjectId: string; localId: string },
SetAccountInfoResponse
>("/v1/accounts:update", {
disableUser: disabled,
targetProjectId: project,
localId: uid,
});
return res.status === 200;
}
Loading