setExternalSession method
Future<RequestResponse<FrappeSessionStatusInfo?> >
setExternalSession(
- FrappeSessionStatusInfo? sessionStatusInfo
override
Sets the session locally obtained externally and validates against the backend.
Useful when a custom API returns a session object, "Sign Up", for instance.
The session must be valid. In case the session is to be cleared, use logout.
Implementation
@override
Future<RequestResponse<FrappeSessionStatusInfo?>> setExternalSession(
FrappeSessionStatusInfo? sessionStatusInfo) async {
assert(sessionStatusInfo != null || sessionStatusInfo?.user != null,
'Only a valid session can be set.\nUse .logout() if you want to clear the session');
if (_useJwt) {
assert(sessionStatusInfo?.token != null, 'Token missing in the session');
}
// If JWT is used, set the token.
if (_useJwt) {
setAuthToken(sessionStatusInfo!.token);
}
return await verifySessionWithBackend(
sessionStatusInfo!..currentUser = sessionStatusInfo.user,
shouldUpdateSession: true,
);
}