(core) Fix delete user button for Google-only accounts

Summary:
An unhandled error was being thrown by CognitoClient when a user was unable
to be found during account deletion. Google-only accounts are no longer
associated with a user in Cognito, so the error was actually benign. A warning is
now logged instead.

Test Plan: Manual.

Reviewers: paulfitz, jarek

Reviewed By: paulfitz, jarek

Differential Revision: https://phab.getgrist.com/D4073
This commit is contained in:
George Gevoian 2023-10-18 10:31:58 -04:00
parent f6256646ef
commit 74485f412d
3 changed files with 7 additions and 6 deletions

View File

@ -117,8 +117,7 @@ export class Doom {
await this._notifier.deleteUser(userId); await this._notifier.deleteUser(userId);
// Remove user from cognito // Remove user from cognito
const fullUser = this._dbManager.makeFullUser(user); await this._loginSystem.deleteUser(user);
await this._loginSystem.deleteUser(fullUser);
// Remove user from our db // Remove user from our db
await this._dbManager.deleteUser({userId}, userId); await this._dbManager.deleteUser({userId}, userId);

View File

@ -1,7 +1,8 @@
import { GristDeploymentType, GristLoadConfig } from 'app/common/gristUrls'; import { GristDeploymentType, GristLoadConfig } from 'app/common/gristUrls';
import { FullUser, UserProfile } from 'app/common/UserAPI'; import { UserProfile } from 'app/common/UserAPI';
import { Document } from 'app/gen-server/entity/Document'; import { Document } from 'app/gen-server/entity/Document';
import { Organization } from 'app/gen-server/entity/Organization'; import { Organization } from 'app/gen-server/entity/Organization';
import { User } from 'app/gen-server/entity/User';
import { Workspace } from 'app/gen-server/entity/Workspace'; import { Workspace } from 'app/gen-server/entity/Workspace';
import { Activations } from 'app/gen-server/lib/Activations'; import { Activations } from 'app/gen-server/lib/Activations';
import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager'; import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager';
@ -57,7 +58,7 @@ export interface GristServer {
export interface GristLoginSystem { export interface GristLoginSystem {
getMiddleware(gristServer: GristServer): Promise<GristLoginMiddleware>; getMiddleware(gristServer: GristServer): Promise<GristLoginMiddleware>;
deleteUser(user: FullUser): Promise<void>; deleteUser(user: User): Promise<void>;
} }
export interface GristLoginMiddleware { export interface GristLoginMiddleware {

View File

@ -260,8 +260,9 @@ export async function getSamlLoginSystem(): Promise<GristLoginSystem|undefined>
}, },
}; };
}, },
deleteUser() { async deleteUser() {
throw new Error('users cannot be deleted with SAML yet'); // If we could delete the user account in the external
// authentication system, this is our chance - but we can't.
}, },
}; };
} }