jac-cl-auth

Implements client-side signup, login, logout, and route protection in Jac applications.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/PMN123/trapdoor --skill jac-cl-auth-pmn123
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: jac-cl-auth
Source: https://github.com/PMN123/trapdoor/tree/main/.agents/skills/jac-cl-auth
Command: npx skills add https://github.com/PMN123/trapdoor --skill jac-cl-auth-pmn123

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building authentication UI in Jac client code fails silently when developers misuse the @jac/runtime auth helpers: jacSignup returns a dict rather than a bool, signup does not establish a session, and un-awaited async calls or undeclared variables cause runtime errors that pass compilation. This Skill encodes the correct call patterns so auth flows work on the first attempt. ## Core Features & Use Cases - Correct helper usage: Documents the exact return types of jacSignup (dict), jacLogin (bool), jacLogout (sync), and jacIsLoggedIn (sync), including the truthy-dict pitfall that makes if not signup_result useless. - Signup-then-login sequencing: Enforces the three awaited steps (signup, login, then privileged server calls) so def:priv endpoints receive an authenticated session instead of a 401. - Route protection: Shows AuthGuard-based layout protection for file-based route groups plus inline jacIsLoggedIn() guards, and SSO login via jacSsoLogin with server-side provider configuration. - Use Case: When adding a registration form that also saves a user profile, follow the Skill's pattern to await signup, await login, then call the privileged save endpoint, avoiding the silent unauthenticated-request failure. ## Quick Start Add a login and signup flow to my Jac app using the @jac/runtime auth helpers, with an AuthGuard protecting the dashboard route.

Frequently Asked Questions about jac-cl-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement login and signup in a Jac client app?

Import jacLogin and jacSignup from @jac/runtime and await both in an async handler. jacLogin returns a bool, while jacSignup returns a dict whose success key must be checked. Always call jacLogin after jacSignup because signup alone does not establish a session.

How do I protect routes from unauthenticated users in Jac?

Wrap protected pages in the AuthGuard component from @jac/runtime with a redirect to the login page. With file-based routing, place AuthGuard in a layout so every page in that route group requires login; use inline jacIsLoggedIn checks only for one-off cases.

Why does my Jac signup succeed but the next server call returns 401?

jacSignup creates the account but does not establish a session, so subsequent def:priv calls arrive unauthenticated. Await jacLogin with the same credentials after signup, then await the privileged call, in that fixed order.

Why does checking 'if not signup_result' never catch a failed Jac signup?

jacSignup returns a dict shaped {"success": bool, ...} that is always non-empty and therefore truthy. Check the success key explicitly with if not signup_result["success"], and type the variable as dict, not bool, to avoid E1001 compile errors.

Does Jac support SSO login with providers like Google?

Yes. Configure the provider under [scale.sso.google] in jac.toml on the server, which exposes /sso/{platform}/login and callback endpoints. On the client, await jacSsoLogin("google") to hand off to the provider, or use jacSetToken to store a token directly.

Why does my Jac login handler throw ReferenceError at runtime?

Assigning an await result without pre-declaring the variable can compile to a tightly scoped JS let, so the later if-check throws ReferenceError. Declare the variable with a default at the top of the function, such as ok: bool = False, then assign the awaited result.