Skip to content

v0.27.0 — authentication

Choose a tag to compare

@tshafer tshafer released this 10 Jul 21:16

Session-based auth, tying together the session + hash primitives:

setUserProvider((id) => db.users.find(id));  // once, in a provider

if (user && await hash.verify(user.password, password)) {
  auth().login(user.id);
}
auth().check();  auth().id();  await auth().user();  auth().logout();

Protect routes with the authGuard({ redirectTo? }) middleware (401 for APIs, redirect for web). See docs/authentication.md.