clearAuth method

Future<void> clearAuth()

Implementation

Future<void> clearAuth() async {
  try {
    final keys = [
      '${_authPrefix}uid',
      '${_authPrefix}token',
      '${_authPrefix}role',
      '${_authPrefix}mfa_code',
      '${_authPrefix}mfa_expiry',
      '${_authPrefix}custom',
    ];

    await Future.wait(keys.map((key) => _storage.delete(key: key)));

    batch(() {
      uid.value = null;
      token.value = null;
      role.value = null;
      mfaCode.value = null;
      mfaCodeExpiry.value = null;
      customFields.value = {};
    });
  } catch (e) {
    throw StorageException(
      'Error limpiando autenticación',
      details: e.toString(),
      type: StorageType.auth,
    );
  }
}