MCPcopy Index your code
hub / github.com/monkeytypegame/monkeytype / reauthenticate

Function reauthenticate

frontend/src/ts/auth.tsx:376–455  ·  view source on GitHub ↗
(
  options: ReauthenticateOptions,
)

Source from the content-addressed store, hash-verified

374}
375
376export async function reauthenticate(
377 options: ReauthenticateOptions,
378): Promise<ReauthSuccess | ReauthFailed> {
379 if (!isAuthAvailable()) {
380 return {
381 status: "error",
382 message: "Authentication is not initialized",
383 };
384 }
385
386 const user = getAuthenticatedUser();
387 if (user === null) {
388 return {
389 status: "error",
390 message: "User is not signed in",
391 };
392 }
393
394 const authMethod = getPreferredAuthenticationMethod(options.excludeMethod);
395
396 try {
397 if (authMethod === undefined) {
398 return {
399 status: "error",
400 message:
401 "Failed to reauthenticate: there is no valid authentication present on the account.",
402 };
403 }
404
405 if (authMethod === "password") {
406 if (options.password === undefined) {
407 return {
408 status: "error",
409 message: "Failed to reauthenticate using password: password missing.",
410 };
411 }
412 const credential = EmailAuthProvider.credential(
413 user.email as string,
414 options.password,
415 );
416 await reauthenticateWithCredential(user, credential);
417 } else {
418 const provider = getAuthProvider(authMethod);
419 if (provider === undefined) {
420 return {
421 status: "error",
422 message: `Authentication ${authMethod} is missing a provider`,
423 };
424 }
425 await reauthenticateWithPopup(user, provider);
426 }
427
428 return {
429 status: "success",
430 message: "Reauthenticated",
431 user,
432 };
433 } catch (e) {

Callers 6

showUpdatePasswordModalFunction · 0.90
showUpdateNameModalFunction · 0.90
showUpdateEmailModalFunction · 0.90
showAddPasswordAuthModalFunction · 0.90
showReauthConfirmModalFunction · 0.90
removeAuthProviderFunction · 0.85

Calls 4

isAuthAvailableFunction · 0.90
getAuthenticatedUserFunction · 0.90
getAuthProviderFunction · 0.85

Tested by

no test coverage detected