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

Function addAuthProvider

frontend/src/ts/auth.tsx:244–270  ·  view source on GitHub ↗
(authMethod: AuthMethod)

Source from the content-addressed store, hash-verified

242}
243
244export async function addAuthProvider(authMethod: AuthMethod): Promise<void> {
245 if (!isAuthAvailable()) {
246 showErrorNotification("Authentication uninitialized", { durationMs: 3000 });
247 return;
248 }
249 const provider = getAuthProvider(authMethod);
250 if (provider === undefined) {
251 showErrorNotification(`Authentication ${authMethod} is missing a provider`);
252 return;
253 }
254 const providerName = getAuthMethodDisplay(authMethod);
255
256 showLoaderBar();
257 const user = getAuthenticatedUser();
258 if (!user) return;
259 try {
260 await linkWithPopup(user, provider);
261 hideLoaderBar();
262 showSuccessNotification(`${providerName} authentication added`);
263 authEvent.dispatch({ type: "authConfigUpdated" });
264 } catch (error) {
265 hideLoaderBar();
266 showErrorNotification(`Failed to add ${providerName} authentication`, {
267 error,
268 });
269 }
270}
271
272export async function removeAuthProvider(
273 authMethod: AuthMethod,

Callers 1

Calls 7

isAuthAvailableFunction · 0.90
showErrorNotificationFunction · 0.90
getAuthenticatedUserFunction · 0.90
showSuccessNotificationFunction · 0.90
getAuthProviderFunction · 0.85
getAuthMethodDisplayFunction · 0.85
dispatchMethod · 0.80

Tested by

no test coverage detected