MCPcopy Create free account
hub / github.com/dfinity/orbit / initializeAuthenticated

Function initializeAuthenticated

apps/wallet/src/stores/session.store.ts:356–401  ·  view source on GitHub ↗
(newIdentity: Identity, redirectOnAuthenticated = true)

Source from the content-addressed store, hash-verified

354 },
355
356 async initializeAuthenticated(newIdentity: Identity, redirectOnAuthenticated = true) {
357 const authService = services().auth;
358 icAgent.get().replaceIdentity(newIdentity);
359
360 if (
361 this.lastLoginPrincipal !== null &&
362 this.lastLoginPrincipal !== newIdentity.getPrincipal().toText()
363 ) {
364 this.reset();
365 }
366
367 this.reauthenticationNeeded = false;
368 enableWorkers();
369
370 const sessionExpirationService = services().sessionExpiration;
371
372 const maybeSessionExpirationTimeMs = await authService.getRemainingSessionTimeMs();
373 if (maybeSessionExpirationTimeMs) {
374 sessionExpirationService.resetSessionTimeout(maybeSessionExpirationTimeMs);
375 }
376 sessionExpirationService.resetInactivityTimeout();
377
378 const controlPanelService = services().controlPanel;
379 const isRegistered = await controlPanelService.hasRegistration();
380
381 if (!isRegistered) {
382 await controlPanelService.register({
383 // a new user is created with an empty list of stations, they can add them later
384 station: [],
385 });
386 }
387
388 // loads information about the authenticated user
389 await this.load(redirectOnAuthenticated);
390
391 // if the user was not signed in before, or the user signed in with a different identity
392 if (
393 this.lastLoginPrincipal !== null &&
394 this.lastLoginPrincipal !== newIdentity.getPrincipal().toText() &&
395 this.lastLoginPrincipal !== Principal.anonymous().toText()
396 ) {
397 afterLoginRedirect();
398 }
399
400 this.lastLoginPrincipal = newIdentity.getPrincipal().toText();
401 },
402 },
403});

Callers

nothing calls this directly

Calls 10

servicesFunction · 0.90
enableWorkersFunction · 0.90
afterLoginRedirectFunction · 0.90
resetMethod · 0.80
resetSessionTimeoutMethod · 0.80
hasRegistrationMethod · 0.80
getMethod · 0.45
registerMethod · 0.45

Tested by

no test coverage detected