checkLogin method

  1. @override
Future<RequestResponse<FrappeSessionStatusInfo?>> checkLogin({
  1. bool? shouldUpdateSession = true,
})
override

Checks the session's status (Whether the user is logged in or not) and returns it as FrappeSessionStatusInfo.

If it exists locally, the status will be compared between the server's session.

Only if shouldUpdateSession is set to true, the sessionStatus will be updated.

By default, sessionStatus is updated.

Implementation

@override
Future<RequestResponse<FrappeSessionStatusInfo?>> checkLogin(
    {bool? shouldUpdateSession = true}) async {
  var currentSession = getSession();
  if (currentSession != null && currentSession.loggedIn == true) {
    return await verifySessionWithBackend(currentSession,
        shouldUpdateSession: shouldUpdateSession);
  } else {
    // no login info or not logged in
    currentSession = FrappeSessionStatusInfo(false,
        (DateTime.now().millisecondsSinceEpoch / 1000).floor().toDouble());
    return RequestResponse.fail(
        ErrorDetail(info: Information(httpCode: 403, data: currentSession)));
  }
}