From be3c4d12d249e8680a5987e14b7008b283f59c72 Mon Sep 17 00:00:00 2001 From: Alexander Nohe Date: Thu, 24 Apr 2025 13:21:40 -0700 Subject: [PATCH 1/3] Add in disable_user to auth calls --- src/gcp/auth.ts | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/gcp/auth.ts b/src/gcp/auth.ts index f0480a7ec6e..d27bc06d2c8 100644 --- a/src/gcp/auth.ts +++ b/src/gcp/auth.ts @@ -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. @@ -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). + * @returns the call succeeded (true). + */ +export async function disableUser(project:string, uid:string, disabled:boolean): Promise { + 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); + +} From 6095861e5c65e75736830844137c10f220c3787e Mon Sep 17 00:00:00 2001 From: Alexander Nohe Date: Thu, 24 Apr 2025 13:59:46 -0700 Subject: [PATCH 2/3] Fix linting error --- src/gcp/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gcp/auth.ts b/src/gcp/auth.ts index d27bc06d2c8..dfaf8fc7f20 100644 --- a/src/gcp/auth.ts +++ b/src/gcp/auth.ts @@ -63,7 +63,7 @@ export async function updateAuthDomains(project: string, authDomains: string[]): * @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). - * @returns the call succeeded (true). + * @return the call succeeded (true). */ export async function disableUser(project:string, uid:string, disabled:boolean): Promise { const res = await apiClient.post< From 279d93496842e4250831ab13d029ee1bf2f0c203 Mon Sep 17 00:00:00 2001 From: Alexander Nohe Date: Thu, 24 Apr 2025 14:08:41 -0700 Subject: [PATCH 3/3] More lint fixes --- src/gcp/auth.ts | 54 ++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/gcp/auth.ts b/src/gcp/auth.ts index dfaf8fc7f20..c9831c9ecf9 100644 --- a/src/gcp/auth.ts +++ b/src/gcp/auth.ts @@ -4,24 +4,24 @@ 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 + 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 + localId: string; + idToken: string; + providerUserInfo: ProviderUserInfo[]; + newEmail: string; + refreshToken: string; + expiresIn: string; + emailVerified: boolean; } /** @@ -65,18 +65,18 @@ export async function updateAuthDomains(project: string, authDomains: string[]): * @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 { +export async function disableUser( + project: string, + uid: string, + disabled: boolean, +): Promise { const res = await apiClient.post< - { disableUser: boolean, targetProjectId: string, localId: string }, + { disableUser: boolean; targetProjectId: string; localId: string }, SetAccountInfoResponse - >( - '/v1/accounts:update', - { - disableUser: disabled, - targetProjectId: project, - localId: uid, - }, - ); - return (res.status == 200); - + >("/v1/accounts:update", { + disableUser: disabled, + targetProjectId: project, + localId: uid, + }); + return res.status === 200; }