{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla/teach.webmaker.org/issues/984","labels_url":"https://api.github.com/repos/mozilla/teach.webmaker.org/issues/984/labels{/name}","comments_url":"https://api.github.com/repos/mozilla/teach.webmaker.org/issues/984/comments","events_url":"https://api.github.com/repos/mozilla/teach.webmaker.org/issues/984/events","html_url":"https://github.com/mozilla/teach.webmaker.org/pull/984","id":84124635,"number":984,"title":"Only emit \"username:change\" when the username actually changes.","user":{"login":"toolness","id":124687,"avatar_url":"https://avatars.githubusercontent.com/u/124687?v=3","gravatar_id":"","url":"https://api.github.com/users/toolness","html_url":"https://github.com/toolness","followers_url":"https://api.github.com/users/toolness/followers","following_url":"https://api.github.com/users/toolness/following{/other_user}","gists_url":"https://api.github.com/users/toolness/gists{/gist_id}","starred_url":"https://api.github.com/users/toolness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toolness/subscriptions","organizations_url":"https://api.github.com/users/toolness/orgs","repos_url":"https://api.github.com/users/toolness/repos","events_url":"https://api.github.com/users/toolness/events{/privacy}","received_events_url":"https://api.github.com/users/toolness/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mozilla/teach.webmaker.org/labels/PR%20needs%20review","name":"PR needs review","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"mmmavis","id":2896608,"avatar_url":"https://avatars.githubusercontent.com/u/2896608?v=3","gravatar_id":"","url":"https://api.github.com/users/mmmavis","html_url":"https://github.com/mmmavis","followers_url":"https://api.github.com/users/mmmavis/followers","following_url":"https://api.github.com/users/mmmavis/following{/other_user}","gists_url":"https://api.github.com/users/mmmavis/gists{/gist_id}","starred_url":"https://api.github.com/users/mmmavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmmavis/subscriptions","organizations_url":"https://api.github.com/users/mmmavis/orgs","repos_url":"https://api.github.com/users/mmmavis/repos","events_url":"https://api.github.com/users/mmmavis/events{/privacy}","received_events_url":"https://api.github.com/users/mmmavis/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2015-06-02T17:46:38Z","updated_at":"2015-06-03T20:55:47Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mozilla/teach.webmaker.org/pulls/984","html_url":"https://github.com/mozilla/teach.webmaker.org/pull/984","diff_url":"https://github.com/mozilla/teach.webmaker.org/pull/984.diff","patch_url":"https://github.com/mozilla/teach.webmaker.org/pull/984.patch"},"body":"In #965 I changed the behavior of TeachAPI so it re-triggers fetching of clubs whenever the current user changes, but the `username:change` event is actually fired when the current user *doesn't* change, which ultimately results in spurious re-fetches of the club list.\r\n\r\nThis fixes things so the `username:change` event is only fired when the current username *actually* changes."},"comment":{"url":"https://api.github.com/repos/mozilla/teach.webmaker.org/issues/comments/108613970","html_url":"https://github.com/mozilla/teach.webmaker.org/pull/984#issuecomment-108613970","issue_url":"https://api.github.com/repos/mozilla/teach.webmaker.org/issues/984","id":108613970,"user":{"login":"toolness","id":124687,"avatar_url":"https://avatars.githubusercontent.com/u/124687?v=3","gravatar_id":"","url":"https://api.github.com/users/toolness","html_url":"https://github.com/toolness","followers_url":"https://api.github.com/users/toolness/followers","following_url":"https://api.github.com/users/toolness/following{/other_user}","gists_url":"https://api.github.com/users/toolness/gists{/gist_id}","starred_url":"https://api.github.com/users/toolness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toolness/subscriptions","organizations_url":"https://api.github.com/users/toolness/orgs","repos_url":"https://api.github.com/users/toolness/repos","events_url":"https://api.github.com/users/toolness/events{/privacy}","received_events_url":"https://api.github.com/users/toolness/received_events","type":"User","site_admin":false},"created_at":"2015-06-03T20:55:47Z","updated_at":"2015-06-03T20:55:47Z","body":"> Some Teach API questions: How is token generated? Is it associated with username and something else like timestamp or it's solely based on username?\r\n\r\nIt's just an opaque identifier generated, ultimately, by Django REST framework's [`TokenAuthentication`](http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication) system. We only generate it once, so it's actually fairly long-lived, but we can regenerate it more frequently later if we want.\r\n\r\n> Just wondering why we always check if `username` matches or exists but not `token`.  Is it because username is more human readable?\r\n\r\nThe main reason is because we already needed a `getUsername()` method that dealt with annoying edge cases (so that the login component could display the current user), and it was just easier to re-use that than make a new method that dealt with the same kinds of edge cases.\r\n\r\nAlso, since some code (like the login component) *only* needs that information, it was simpler to just have the `null` value communicate that nobody's currently logged in, rather than e.g. communicate a boolean indicating whether the user was logged in, and a string indicating their username if so.\r\n\r\nDoes that make sense?\r\n"}}