switchSession method
Switches the activeSession to the one associated with userId and optionally with the mid and businessId.
If no session exists for the given user, it will be fetched or created.
Switches the activeSession to the one associated with userId and optionally with the mid and businessId.
If no session exists for the given user, it will be fetched or created.
pin Optional PIN for session creation when PIN verification is required.
Implementation
Future<AuthUserSession> switchSession({
required String userId,
String? mid,
String? businessId,
bool refresh = false,
String? pin,
}) {
return monitoringService.monitorAction<AuthUserSession>(
actionName: 'switch_session',
provider: _providerName,
attributes: {'userId': userId},
action: (trace) async {
_ensureInitialized();
logger.info(this, 'Switching active session to user $userId.');
var session = await getOrCreateSession(
userId: userId,
mid: mid,
refresh: refresh,
businessId: businessId,
pin: pin,
);
await validateSession(session);
await _localSessionRepository.setActiveSession(session);
return session;
},
);
}