Refactor Out Admin and Account Controllers
Ticket
Refactor Out Admin and Account Controllers+issues
Now that we almost have the User model connected through cards in account_cards pull request., it is time to make these controllers into card functions.
This should be the right time to add events, which should be exactly what we need for this problem.
Refactor Out Admin and Account Controllers+solution
Replace all special action handlers in controllers with event handlers declared on the base CRUD actions and maybe a few special Wagn core events as well.
Cool! Let's spell out the api in detail here for each method.
Admin Controller
/admin/setup
Hrmm. add a :setup card? GET it for the form, PUT (or POST?) to it for the setup? params should follow pattern of signup (below)
√ /admin/show_cache
Easy one. Just add a :cache view. Eg. /my_card?view=cache
/admin/clear_cache
I'm thinking we add a :cache card. Content is overview of cache usage (for whole site, unlike show_cache above, which is for a single card).
Then to clear the cache, maybe DELETE /:cache? As with session, this isn't an actual deletion...
/admin/tasks
# already deprecated. only real todo here is to migrate away old links where possible.
Account Controller
/account/signin
POST (or PUT?) to :session card
(POST makes more conceptual sense, as we're creating a session, but PUT may make more practical sense, since PUT statements expect an existing card. Same goes for admin/setup)
/account/signout
DELETE /:session
√ /account/signup
GET /:account_request?view=new
POST (new account request card)
/account/forgot_password
GET /(account card)+(:password)?view=edit
PUT /(account card)+(:password)
# custom events to generate new password or verification code or whatever
√ /account/invite
GET /:user?view=new
POST (user card)
√/account/accept
√/card/update_account
PUT /(account card)
# needs some param design
√/card/create_account
POST (new account card)
/card/rollback
/card/watch
√ /card/comment
/card/save_draft
will work on these soon...
Refactor Out Admin and Account Controllers+example
CardController#create_account is handled by an event handler on CardController#create. This handler would do the former create_account action for a set: Self::CreateAccount on the :create event.
Similar for CardController#update_account, likely a PUT request to the same resource.
AccountController#signin would be a Set::Self::Session#create action, and it would do signin, that is bind the account card to the web-session. Signout out DELETE /:session (name *session or *user or ...)