MCPcopy
hub / github.com/monkeytypegame/monkeytype / removeAuthProvider

Function removeAuthProvider

frontend/src/ts/auth.tsx:272–305  ·  view source on GitHub ↗
(
  authMethod: AuthMethod,
  options?: { password?: string },
)

Source from the content-addressed store, hash-verified

270}
271
272export async function removeAuthProvider(
273 authMethod: AuthMethod,
274 options?: { password?: string },
275): Promise<ReauthSuccess | ReauthFailed> {
276 const reauth = await reauthenticate({
277 password: options?.password,
278 excludeMethod: authMethod,
279 });
280 if (reauth.status !== "success") {
281 return {
282 status: reauth.status,
283 message: reauth.message,
284 };
285 }
286 try {
287 await unlink(reauth.user, getProviderId(authMethod));
288 } catch (e) {
289 const message = createErrorMessage(
290 e,
291 authMethod === "password"
292 ? "Failed to remove password authentication"
293 : `Failed to unlink ${getAuthMethodDisplay(authMethod)} account`,
294 );
295 return {
296 status: "error",
297 message,
298 };
299 }
300 return {
301 status: "success",
302 message: `${getAuthMethodDisplay(authMethod)} authentication removed`,
303 user: reauth.user,
304 };
305}
306
307export function signOut(): void {
308 if (!isAuthAvailable()) {

Callers 1

Calls 4

createErrorMessageFunction · 0.90
reauthenticateFunction · 0.85
getProviderIdFunction · 0.85
getAuthMethodDisplayFunction · 0.85

Tested by

no test coverage detected