[**Documentation**](../../../README)

***

[Documentation](../../../README) / [zerotal](../../README) / [auth](../README) / Authenticatable

# Function: Authenticatable()

> **Authenticatable**\<`TBase`\>(`Base`): \{(...`args`): `Authenticatable`; `prototype`: `Authenticatable`\<`any`\>; \} & `TBase`

Defined in: [packages/auth/src/Authenticatable.ts:46](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/auth/src/Authenticatable.ts#L46)

The authenticatable contract as a composable mixin: identity (`getAuthId`) and
the hashed password (`getAuthPassword`), plus "remember me" token accessors.
Stack it with `BaseModelWith` instead of nesting wrappers around a concrete base.

## Type Parameters

### TBase

`TBase` *extends* [`Constructor`](../../orm/type-aliases/Constructor)

## Parameters

### Base

`TBase`

## Returns

\{(...`args`): `Authenticatable`; `prototype`: `Authenticatable`\<`any`\>; \} & `TBase`

## Remarks

These are the methods the auth flow reads: `getAuthId()` is stored in the
session by [Auth.login](../variables/Auth#login) and identifies the user; `getAuthPassword()` is
what [Auth.attempt](../variables/Auth#attempt) / [Auth.confirmPassword](../variables/Auth#confirmpassword) verify against (returns
`null` for passwordless auth); the `RememberToken` accessors back the persistent
"remember me" cookie. Applying the mixin also brands the class (so
[isAuthenticatable](isAuthenticatable) detects it) and registers the `remember_token` column.

For the common single-contract case, `extends AuthUser` (which is just
`Authenticatable(BaseModel)`) reads fine too.

## Example

```ts
import { BaseModelWith } from "@zerotal/orm";
import { Authenticatable, Permissions, Roles } from "@zerotal/auth";

class User extends BaseModelWith(Authenticatable) {
  @column() email!: string;
  @column() password!: string;
}

// with roles + permissions, still flat:
class AdminUser extends BaseModelWith(Authenticatable, Permissions, Roles) {}
```
