stopImpersonating method

Future<void> stopImpersonating()

Stop impersonating a user

Implementation

Future<void> stopImpersonating() async {
  try {
    await super.dio.post(
      "/admin/stop-impersonating",
      options: await super.getOptions(isTokenRequired: true),
    );
    final adminToken = await super.tokenStore.getAdminToken(); // Get the saved "admin" user token
    assert(adminToken.isNotEmpty, "Admin token is empty");
    await super.tokenStore.saveToken(adminToken); // Replace the "admin" user token with the saved "admin" user token
  } catch (e) {
    final message = getErrorMessage(e);
    if (message == null) rethrow;
    throw message;
  }
}