Documentation / zerotal / auth / Authenticatable
Function: Authenticatable()
Authenticatable<
TBase>(Base): {(...args):Authenticatable;prototype:Authenticatable<any>; } &TBase
Defined in: packages/auth/src/Authenticatable.ts:46
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
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 and identifies the user; getAuthPassword() is
what Auth.attempt / 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 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
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) {}