{"action":"created","issue":{"url":"https://api.github.com/repos/timwis/enviar/issues/65","repository_url":"https://api.github.com/repos/timwis/enviar","labels_url":"https://api.github.com/repos/timwis/enviar/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/timwis/enviar/issues/65/comments","events_url":"https://api.github.com/repos/timwis/enviar/issues/65/events","html_url":"https://github.com/timwis/enviar/issues/65","id":174968272,"number":65,"title":"Where should login status be checked at init?","user":{"login":"timwis","id":761444,"avatar_url":"https://avatars.githubusercontent.com/u/761444?v=3","gravatar_id":"","url":"https://api.github.com/users/timwis","html_url":"https://github.com/timwis","followers_url":"https://api.github.com/users/timwis/followers","following_url":"https://api.github.com/users/timwis/following{/other_user}","gists_url":"https://api.github.com/users/timwis/gists{/gist_id}","starred_url":"https://api.github.com/users/timwis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timwis/subscriptions","organizations_url":"https://api.github.com/users/timwis/orgs","repos_url":"https://api.github.com/users/timwis/repos","events_url":"https://api.github.com/users/timwis/events{/privacy}","received_events_url":"https://api.github.com/users/timwis/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-04T20:34:47Z","updated_at":"2016-09-21T11:48:15Z","closed_at":"2016-09-21T11:48:15Z","body":"Currently, [`layout.js`](../blob/master/client/views/layout.js) has an `onload` callback which triggers the `app` model's `initialize` effect. The `initialize` effect calls pouchdb's [`getSession()`](https://github.com/nolanlawson/pouchdb-authentication#dbgetsessionopts--callback), which [queries couchdb's `_session` endpoint](https://github.com/nolanlawson/pouchdb-authentication/blob/master/lib/index.js#L112-L125) to validate the cookie. If the user is not logged in, the [`app`](../blob/master/client/models/app.js) model's `initialize` effect does a hard redirect to `/login`. If the user _is_ logged in, it sets the user data via the [`user`](../blob/master/client/models/user.js) model's `set` reducer, then triggers the [`convos`](../blob/master/client/models/convos.js) model's `fetch` effect to get all the messages as a logged in user.\r\n\r\nThis works pretty well, but it doesn't _feel_ right to have this done in the onload callback inside a big effect.\r\n\r\nA more traditional approach would have some sort of validation happening in the router, but I can't quite get a good workflow going. The only thing I can think of that would truly work is to do the checking prior to `app.start()`. If the user's not logged in, redirect them to `/login`, otherwise pass their initial state (we'd have to wrap the model in a function to accept initial state). But having a server side call before render seems bad."},"comment":{"url":"https://api.github.com/repos/timwis/enviar/issues/comments/248588126","html_url":"https://github.com/timwis/enviar/issues/65#issuecomment-248588126","issue_url":"https://api.github.com/repos/timwis/enviar/issues/65","id":248588126,"user":{"login":"timwis","id":761444,"avatar_url":"https://avatars.githubusercontent.com/u/761444?v=3","gravatar_id":"","url":"https://api.github.com/users/timwis","html_url":"https://github.com/timwis","followers_url":"https://api.github.com/users/timwis/followers","following_url":"https://api.github.com/users/timwis/following{/other_user}","gists_url":"https://api.github.com/users/timwis/gists{/gist_id}","starred_url":"https://api.github.com/users/timwis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timwis/subscriptions","organizations_url":"https://api.github.com/users/timwis/orgs","repos_url":"https://api.github.com/users/timwis/repos","events_url":"https://api.github.com/users/timwis/events{/privacy}","received_events_url":"https://api.github.com/users/timwis/received_events","type":"User","site_admin":false},"created_at":"2016-09-21T11:48:15Z","updated_at":"2016-09-21T11:48:15Z","body":"Moved `getSession()` to `index.js`, outside of choo. Works pretty well, though doesn't feel very chooy."}}
{"actor":{"display_login":"timwis"}}