(newIdentity: Identity, redirectOnAuthenticated = true)
| 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 | }); |
nothing calls this directly
no test coverage detected