GitHub PullRequestReviewCommentEvent at 2014-08-12 10:43:21
Repository: angular-token-auth
Actor: grahamgilchrist
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/incuna/angular-token-auth/pulls/comments/16106080","id":16106080,"diff_hunk":"@@ -137,23 +137,87 @@\n         authenticationFactory.logout();\n     }]);\n \n-    auth.factory('tokenFactory', ['$rootScope', '$cookieStore', function ($rootScope, $cookieStore) {\n+    auth.factory('tokenStorageFactory', ['$cookieStore', '$window', function ($cookieStore, $window) {\n+\n+        var storageMethods = {\n+            noSupport: {\n+                // No supported storage methods, but we have to return empty functions so the \n+                //  interface doesn't break\n+                set: function () {},\n+                get: function () {},\n+                clear: function () {}\n+            },\n+            cookie: {\n+                test: function () {\n+                    // Return true if browser has cookie support. Using angular $cookieStore incorrectly \n+                    //  returns true here when cookies are not supported because of internal caching \n+                    //  between digest cycles.\n+                    //  For this reason we interact with the document cookies directly\n+                    document.cookie = 'testcookie=test';\n+                    var cookieEnabled = (document.cookie.indexOf('testcookie') !== -1) ? true : false;\n+                    //delete test cookie by setting old expiry date\n+                    document.cookie = 'testcookie=test;expires=Thu, 01-Jan-1970 00:00:01 GMT';\n+                    return cookieEnabled;\n+                },\n+                set: function (key, value) {\n+                    $cookieStore.put(key, value);\n+                },\n+                get: function (key) {\n+                    return $cookieStore.get(key);\n+                },\n+                clear: function (key) {\n+                    $cookieStore.remove(key);\n+                }\n+            },\n+            localStorage: {\n+                test: function () {\n+                    return angular.isDefined($window.localStorage);\n+                },\n+                set: function (key, value) {\n+                    $window.localStorage.setItem(key, angular.toJson(value));\n+                },\n+                get: function (key) {\n+                    var value;\n+                    var jsonObject = $window.localStorage.getItem(key);\n+                    if (jsonObject) {\n+                        value = angular.fromJson(jsonObject);\n+                    }\n+                    return value;","path":"angular_token_auth.js","position":50,"original_position":56,"commit_id":"c1133c48449ef488689bc93737b88c659ea58e6a","original_commit_id":"80600ad9858a907a74f7471aa3cabac61902f30b","user":{"login":"grahamgilchrist","id":632974,"avatar_url":"https://avatars.githubusercontent.com/u/632974?v=2","gravatar_id":"a945e73af7e5cc6450a5a56fdf7e3a20","url":"https://api.github.com/users/grahamgilchrist","html_url":"https://github.com/grahamgilchrist","followers_url":"https://api.github.com/users/grahamgilchrist/followers","following_url":"https://api.github.com/users/grahamgilchrist/following{/other_user}","gists_url":"https://api.github.com/users/grahamgilchrist/gists{/gist_id}","starred_url":"https://api.github.com/users/grahamgilchrist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grahamgilchrist/subscriptions","organizations_url":"https://api.github.com/users/grahamgilchrist/orgs","repos_url":"https://api.github.com/users/grahamgilchrist/repos","events_url":"https://api.github.com/users/grahamgilchrist/events{/privacy}","received_events_url":"https://api.github.com/users/grahamgilchrist/received_events","type":"User","site_admin":false},"body":"http://dev.w3.org/html5/webstorage/#dom-storage-getitem","created_at":"2014-08-12T10:43:21Z","updated_at":"2014-08-12T10:43:21Z","html_url":"https://github.com/incuna/angular-token-auth/pull/13#discussion_r16106080","pull_request_url":"https://api.github.com/repos/incuna/angular-token-auth/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/incuna/angular-token-auth/pulls/comments/16106080"},"html":{"href":"https://github.com/incuna/angular-token-auth/pull/13#discussion_r16106080"},"pull_request":{"href":"https://api.github.com/repos/incuna/angular-token-auth/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/incuna/angular-token-auth/pulls/13","id":19605462,"html_url":"https://github.com/incuna/angular-token-auth/pull/13","diff_url":"https://github.com/incuna/angular-token-auth/pull/13.diff","patch_url":"https://github.com/incuna/angular-token-auth/pull/13.patch","issue_url":"https://api.github.com/repos/incuna/angular-token-auth/issues/13","number":13,"state":"open","title":"Save token to localStorage","user":{"login":"grahamgilchrist","id":632974,"avatar_url":"https://avatars.githubusercontent.com/u/632974?v=2","gravatar_id":"a945e73af7e5cc6450a5a56fdf7e3a20","url":"https://api.github.com/users/grahamgilchrist","html_url":"https://github.com/grahamgilchrist","followers_url":"https://api.github.com/users/grahamgilchrist/followers","following_url":"https://api.github.com/users/grahamgilchrist/following{/other_user}","gists_url":"https://api.github.com/users/grahamgilchrist/gists{/gist_id}","starred_url":"https://api.github.com/users/grahamgilchrist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grahamgilchrist/subscriptions","organizations_url":"https://api.github.com/users/grahamgilchrist/orgs","repos_url":"https://api.github.com/users/grahamgilchrist/repos","events_url":"https://api.github.com/users/grahamgilchrist/events{/privacy}","received_events_url":"https://api.github.com/users/grahamgilchrist/received_events","type":"User","site_admin":false},"body":"Save token to localStorage as well as $cookieStore to support sites running in local filesystems with no cookie support (e.g. inside cordova apps).","created_at":"2014-08-11T14:51:12Z","updated_at":"2014-08-12T10:43:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"794abc866f82d12256f180c51226c50def721205","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/incuna/angular-token-auth/pulls/13/commits","review_comments_url":"https://api.github.com/repos/incuna/angular-token-auth/pulls/13/comments","review_comment_url":"https://api.github.com/repos/incuna/angular-token-auth/pulls/comments/{number}","comments_url":"https://api.github.com/repos/incuna/angular-token-auth/issues/13/comments","statuses_url":"https://api.github.com/repos/incuna/angular-token-auth/statuses/c1133c48449ef488689bc93737b88c659ea58e6a","head":{"label":"incuna:local-filesystem","ref":"local-filesystem","sha":"c1133c48449ef488689bc93737b88c659ea58e6a","user":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=2","gravatar_id":"722bbd62ec6565c0236a20f9b6939ee1","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"repo":{"id":14398035,"name":"angular-token-auth","full_name":"incuna/angular-token-auth","owner":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=2","gravatar_id":"722bbd62ec6565c0236a20f9b6939ee1","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/incuna/angular-token-auth","description":"","fork":false,"url":"https://api.github.com/repos/incuna/angular-token-auth","forks_url":"https://api.github.com/repos/incuna/angular-token-auth/forks","keys_url":"https://api.github.com/repos/incuna/angular-token-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/incuna/angular-token-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/incuna/angular-token-auth/teams","hooks_url":"https://api.github.com/repos/incuna/angular-token-auth/hooks","issue_events_url":"https://api.github.com/repos/incuna/angular-token-auth/issues/events{/number}","events_url":"https://api.github.com/repos/incuna/angular-token-auth/events","assignees_url":"https://api.github.com/repos/incuna/angular-token-auth/assignees{/user}","branches_url":"https://api.github.com/repos/incuna/angular-token-auth/branches{/branch}","tags_url":"https://api.github.com/repos/incuna/angular-token-auth/tags","blobs_url":"https://api.github.com/repos/incuna/angular-token-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/incuna/angular-token-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/incuna/angular-token-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/incuna/angular-token-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/incuna/angular-token-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/incuna/angular-token-auth/languages","stargazers_url":"https://api.github.com/repos/incuna/angular-token-auth/stargazers","contributors_url":"https://api.github.com/repos/incuna/angular-token-auth/contributors","subscribers_url":"https://api.github.com/repos/incuna/angular-token-auth/subscribers","subscription_url":"https://api.github.com/repos/incuna/angular-token-auth/subscription","commits_url":"https://api.github.com/repos/incuna/angular-token-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/incuna/angular-token-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/incuna/angular-token-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/incuna/angular-token-auth/issues/comments/{number}","contents_url":"https://api.github.com/repos/incuna/angular-token-auth/contents/{+path}","compare_url":"https://api.github.com/repos/incuna/angular-token-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/incuna/angular-token-auth/merges","archive_url":"https://api.github.com/repos/incuna/angular-token-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/incuna/angular-token-auth/downloads","issues_url":"https://api.github.com/repos/incuna/angular-token-auth/issues{/number}","pulls_url":"https://api.github.com/repos/incuna/angular-token-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/incuna/angular-token-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/incuna/angular-token-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/incuna/angular-token-auth/labels{/name}","releases_url":"https://api.github.com/repos/incuna/angular-token-auth/releases{/id}","created_at":"2013-11-14T14:57:48Z","updated_at":"2014-05-23T16:00:08Z","pushed_at":"2014-08-12T09:56:29Z","git_url":"git://github.com/incuna/angular-token-auth.git","ssh_url":"git@github.com:incuna/angular-token-auth.git","clone_url":"https://github.com/incuna/angular-token-auth.git","svn_url":"https://github.com/incuna/angular-token-auth","homepage":null,"size":474,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"base":{"label":"incuna:master","ref":"master","sha":"a613ffb85bbca5134fdb76f99cedbddbce59e288","user":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=2","gravatar_id":"722bbd62ec6565c0236a20f9b6939ee1","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"repo":{"id":14398035,"name":"angular-token-auth","full_name":"incuna/angular-token-auth","owner":{"login":"incuna","id":55510,"avatar_url":"https://avatars.githubusercontent.com/u/55510?v=2","gravatar_id":"722bbd62ec6565c0236a20f9b6939ee1","url":"https://api.github.com/users/incuna","html_url":"https://github.com/incuna","followers_url":"https://api.github.com/users/incuna/followers","following_url":"https://api.github.com/users/incuna/following{/other_user}","gists_url":"https://api.github.com/users/incuna/gists{/gist_id}","starred_url":"https://api.github.com/users/incuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/incuna/subscriptions","organizations_url":"https://api.github.com/users/incuna/orgs","repos_url":"https://api.github.com/users/incuna/repos","events_url":"https://api.github.com/users/incuna/events{/privacy}","received_events_url":"https://api.github.com/users/incuna/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/incuna/angular-token-auth","description":"","fork":false,"url":"https://api.github.com/repos/incuna/angular-token-auth","forks_url":"https://api.github.com/repos/incuna/angular-token-auth/forks","keys_url":"https://api.github.com/repos/incuna/angular-token-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/incuna/angular-token-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/incuna/angular-token-auth/teams","hooks_url":"https://api.github.com/repos/incuna/angular-token-auth/hooks","issue_events_url":"https://api.github.com/repos/incuna/angular-token-auth/issues/events{/number}","events_url":"https://api.github.com/repos/incuna/angular-token-auth/events","assignees_url":"https://api.github.com/repos/incuna/angular-token-auth/assignees{/user}","branches_url":"https://api.github.com/repos/incuna/angular-token-auth/branches{/branch}","tags_url":"https://api.github.com/repos/incuna/angular-token-auth/tags","blobs_url":"https://api.github.com/repos/incuna/angular-token-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/incuna/angular-token-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/incuna/angular-token-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/incuna/angular-token-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/incuna/angular-token-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/incuna/angular-token-auth/languages","stargazers_url":"https://api.github.com/repos/incuna/angular-token-auth/stargazers","contributors_url":"https://api.github.com/repos/incuna/angular-token-auth/contributors","subscribers_url":"https://api.github.com/repos/incuna/angular-token-auth/subscribers","subscription_url":"https://api.github.com/repos/incuna/angular-token-auth/subscription","commits_url":"https://api.github.com/repos/incuna/angular-token-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/incuna/angular-token-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/incuna/angular-token-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/incuna/angular-token-auth/issues/comments/{number}","contents_url":"https://api.github.com/repos/incuna/angular-token-auth/contents/{+path}","compare_url":"https://api.github.com/repos/incuna/angular-token-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/incuna/angular-token-auth/merges","archive_url":"https://api.github.com/repos/incuna/angular-token-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/incuna/angular-token-auth/downloads","issues_url":"https://api.github.com/repos/incuna/angular-token-auth/issues{/number}","pulls_url":"https://api.github.com/repos/incuna/angular-token-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/incuna/angular-token-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/incuna/angular-token-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/incuna/angular-token-auth/labels{/name}","releases_url":"https://api.github.com/repos/incuna/angular-token-auth/releases{/id}","created_at":"2013-11-14T14:57:48Z","updated_at":"2014-05-23T16:00:08Z","pushed_at":"2014-08-12T09:56:29Z","git_url":"git://github.com/incuna/angular-token-auth.git","ssh_url":"git@github.com:incuna/angular-token-auth.git","clone_url":"https://github.com/incuna/angular-token-auth.git","svn_url":"https://github.com/incuna/angular-token-auth","homepage":null,"size":474,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/incuna/angular-token-auth/pulls/13"},"html":{"href":"https://github.com/incuna/angular-token-auth/pull/13"},"issue":{"href":"https://api.github.com/repos/incuna/angular-token-auth/issues/13"},"comments":{"href":"https://api.github.com/repos/incuna/angular-token-auth/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/incuna/angular-token-auth/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/incuna/angular-token-auth/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/incuna/angular-token-auth/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/incuna/angular-token-auth/statuses/c1133c48449ef488689bc93737b88c659ea58e6a"}}}}