Add winn create auth scaffold + auth guide (#168)#182
Merged
Conversation
Final piece of the auth epic (#161): one command scaffolds a complete email/password setup, plus an end-to-end guide. - winn_generator: generate(auth, _) writes User + AuthToken schemas, ordered users/auth_tokens migrations (with constraints), and an AuthController router wiring all eight endpoints (register/login/refresh/logout/verify/forgot/reset/me) with [:cors, :auth] middleware + exclude list. winn_cli: `create auth` dispatch + help text. - Generated models use a schema-only template: the existing model_template emits quoted struct atoms (struct [:"email"]) that don't parse — pre-existing bug in `winn create model`, avoided here. - docs/auth.md: full guide (token model, Bearer vs cookie, account recovery, a runnable JS frontend example). docs/cli.md + roadmap updated. - Fixed `%{ok: true}` examples in docs/modules.md — ok/err are reserved and can't be map keys (confirmed it's a parse error); use `%{status: "ok"}`. - New winn_auth_scaffold_tests runs the generator in a temp dir and compiles the output (controller has 8 routes + [cors,auth]; models compile). Full suite 769 (only the pre-existing esqlite-NIF failure). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
16 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The final piece of the authentication epic (#161):
winn create authscaffolds a complete email/password setup in one command, plus a fulldocs/auth.mdguide. Branched offdevelop.The generated
AuthControllerwires all eight endpoints (register / login / refresh / logout / verify / forgot / reset / me) with[:cors, :auth]middleware and anexcludelist; the migrations are ordered (01/02) with proper constraints.Details
winn_generator:generate(auth, _)+ dedicated templates;winn_cli:create authdispatch + help text.model_templateemits quoted struct atoms (struct [:"email"]) that don't parse — sowinn create modelcurrently generates non-compiling models. The auth scaffold uses a schema-only template that compiles. (Worth a follow-up issue forcreate model.)%{ok: true}indocs/modules.md—ok/errare reserved and can't be map keys (verified it's a parse error); changed to%{status: "ok"}.docs/auth.md: end-to-end guide — quick start, token model, a runnable JS frontend example (with silent refresh), cookie mode, account recovery, security notes.docs/cli.md+docs/roadmap.mdupdated.Testing
New
winn_auth_scaffold_testsruns the generator in a temp dir and compiles the output: the controller compiles + loads with 8 routes and[cors, auth]middleware + anexcludeconfig; both models compile (compiled-not-loaded, so theuserbeam doesn't clobber OTP'susermodule). Also verifiedwinn create authend-to-end via the built escript. Full suite 769, only the pre-existingwinn_sqlite_testsesqlite-NIF failure.Part of #161. Closes #168. This completes the authentication epic — Phases 1–4 all done.
🤖 Generated with Claude Code