# `Ithibati.Credo.NoDirectTableAccess`
[🔗](https://github.com/oliverandrich/ithibati/blob/v0.6.2/lib/ithibati/credo/no_direct_table_access.ex#L4)

## Basics

> #### This check is disabled by default. {: .neutral}
>
> [Learn how to enable it](`e:credo:config_file.html#checks`) via `.credo.exs`.

This check has a base priority of `high` and works with any version of Elixir.

## Explanation

Reach Ithibati's tables through Ithibati, rather than querying them directly.

This is not a matter of taste. A session row is only a sign-in for as long as its
validity allows, which `Ithibati.Identity` checks on every lookup, so a hand-written
query against the sessions table signs somebody in months after they stopped. A recovery
code is single-use, and the
code that spends it enforces that, not the row: a query that reads one directly can spend
it twice. The same applies to the keys table, where a credential is only valid for the
account it was enrolled against.

Read the tables through `Ithibati.Identity` instead. If something you need is not
reachable from there, report it rather than working around it, because the gap is in
Ithibati.

Matching on a struct Ithibati handed you, such as `%Ithibati.UserKey{} = key`, is not
this, and neither is an `alias`. Only using one as the thing being read is.

## Check-Specific Parameters

*There are no specific parameters for this check.*

## General Parameters

Like with all checks, [general params](`e:credo:check_params.html`) can be applied.

Parameters can be configured via the [`.credo.exs` config file](`e:credo:config_file.html`).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
