reauth method

Future<Res> reauth(
  1. String? sid,
  2. String? token,
  3. List<String>? groups
)

Implementation

Future<Res> reauth(
  String? sid,
  String? token,
  List<String>? groups,
) async {
  await getCacheSession();

  sid ??= cacheSession?['_id'];
  token ??= cacheSession?['token'];

  if (sid == null || token == null) {
    throw NoCredsCachedException();
  }
  _onAuthStateChange(AuthState.authing);
  NawahQuery query = NawahQuery($pipe: [
    nawahQueryPipeItem('_id', NawahQueryOper.$eq, sid),
    nawahQueryPipeItem('token', NawahQueryOper.$eq, token),
    nawahQueryPipeItem('groups', NawahQueryOper.$eq, groups ?? []),
  ]);
  Future<Res> call = this
      .call(
    'session/reauth',
    query: query,
  )
      .catchError((err) {
    NawahDI.get<INawahLogger>()?.error(this, 'reauth call err: $err');
    cacheSession = null;
    session = null;
    try {
      if (err['args']['code'] == 'FAILED_REAUTH') {
        clearCacheSession();
      }
    } catch (_) {
      // pass
    }
    _onAuthStateChange(AuthState.notAuthed);
  });

  return call;
}