{"action":"created","comment":{"url":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments/46400096","id":46400096,"diff_hunk":"@@ -0,0 +1,176 @@\n+goog.provide('app.AuthController');\n+goog.provide('app.authDirective');\n+\n+goog.require('app');\n+goog.require('app.Authentication');\n+goog.require('ngeo.Location');\n+\n+\n+/**\n+ * This directive is used to manage the login/register forms.\n+ *\n+ * @return {angular.Directive} The directive specs.\n+ * @ngInject\n+ */\n+app.authDirective = function() {\n+  return {\n+    restrict: 'A',\n+    scope: true,\n+    controller: 'appAuthController',\n+    controllerAs: 'authCtrl',\n+    bindToController: true\n+  };\n+};\n+\n+\n+app.module.directive('appAuth', app.authDirective);\n+\n+\n+\n+/**\n+ * @param {angular.Scope} $scope Scope.\n+ * @param {angular.$http} $http\n+ * @param {string} apiUrl Base URL of the API.\n+ * @param {app.Authentication} appAuthentication\n+ * @param {ngeo.Location} ngeoLocation ngeo Location service.\n+ * @constructor\n+ * @export\n+ * @ngInject\n+ */\n+app.AuthController = function($scope, $http, apiUrl, appAuthentication,\n+    ngeoLocation) {\n+\n+  /**\n+   * @type {angular.Scope}\n+   * @private\n+   */\n+  this.scope_ = $scope;\n+\n+  /**\n+   * @type {angular.$http}\n+   * @private\n+   */\n+  this.http_ = $http;\n+\n+  /**\n+   * @type {string}\n+   * @private\n+   */\n+  this.apiUrl_ = apiUrl;\n+\n+  /**\n+   * @type {app.Authentication}\n+   * @private\n+   */\n+  this.appAuthentication_ = appAuthentication;\n+\n+  /**\n+   * @type {ngeo.Location}\n+   * @private\n+   */\n+  this.ngeoLocation_ = ngeoLocation;\n+};\n+\n+\n+/**\n+ * @export\n+ */\n+app.AuthController.prototype.login = function() {\n+  this.http_.post(this.buildUrl_('login'), this.scope_['login'], {\n+    'headers': {\n+      'Content-Type': 'application/json; charset=UTF-8',\n+      'Accept': 'application/json'\n+    }\n+  }).then(\n+      goog.bind(this.successLogin_, this),\n+      goog.bind(this.errorLogin_, this)\n+  );\n+};\n+\n+\n+/**\n+ * @param {Object} response Response from the API server.\n+ * @private\n+ */\n+app.AuthController.prototype.successLogin_ = function(response) {\n+  this.appAuthentication_.setUserData(response['data']);\n+  // redirect to previous page\n+  var url_from = this.ngeoLocation_.hasParam('from') ?\n+      goog.string.urlDecode(this.ngeoLocation_.getParam('from')) : '/';","path":"c2corg_ui/static/js/auth.js","position":99,"original_position":99,"commit_id":"d3f9e9c4d603ec5035d3a5f10c4fccaffe4f83c7","original_commit_id":"d3f9e9c4d603ec5035d3a5f10c4fccaffe4f83c7","user":{"login":"gberaudo","id":7294662,"avatar_url":"https://avatars.githubusercontent.com/u/7294662?v=3","gravatar_id":"","url":"https://api.github.com/users/gberaudo","html_url":"https://github.com/gberaudo","followers_url":"https://api.github.com/users/gberaudo/followers","following_url":"https://api.github.com/users/gberaudo/following{/other_user}","gists_url":"https://api.github.com/users/gberaudo/gists{/gist_id}","starred_url":"https://api.github.com/users/gberaudo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gberaudo/subscriptions","organizations_url":"https://api.github.com/users/gberaudo/orgs","repos_url":"https://api.github.com/users/gberaudo/repos","events_url":"https://api.github.com/users/gberaudo/events{/privacy}","received_events_url":"https://api.github.com/users/gberaudo/received_events","type":"User","site_admin":false},"body":"Have you tried using `decodeURIComponent`?","created_at":"2015-12-02T10:47:43Z","updated_at":"2015-12-02T10:47:43Z","html_url":"https://github.com/c2corg/v6_ui/pull/36#discussion_r46400096","pull_request_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments/46400096"},"html":{"href":"https://github.com/c2corg/v6_ui/pull/36#discussion_r46400096"},"pull_request":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/c2corg/v6_ui/pulls/36","id":51805008,"html_url":"https://github.com/c2corg/v6_ui/pull/36","diff_url":"https://github.com/c2corg/v6_ui/pull/36.diff","patch_url":"https://github.com/c2corg/v6_ui/pull/36.patch","issue_url":"https://api.github.com/repos/c2corg/v6_ui/issues/36","number":36,"state":"open","locked":false,"title":"Add sign in/up/out actions","user":{"login":"asaunier","id":1192331,"avatar_url":"https://avatars.githubusercontent.com/u/1192331?v=3","gravatar_id":"","url":"https://api.github.com/users/asaunier","html_url":"https://github.com/asaunier","followers_url":"https://api.github.com/users/asaunier/followers","following_url":"https://api.github.com/users/asaunier/following{/other_user}","gists_url":"https://api.github.com/users/asaunier/gists{/gist_id}","starred_url":"https://api.github.com/users/asaunier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asaunier/subscriptions","organizations_url":"https://api.github.com/users/asaunier/orgs","repos_url":"https://api.github.com/users/asaunier/repos","events_url":"https://api.github.com/users/asaunier/events{/privacy}","received_events_url":"https://api.github.com/users/asaunier/received_events","type":"User","site_admin":false},"body":"* [x] Create minimal user directive to handle user-related tools in page header\r\n* [x] Create sign in button redirecting to auth interface\r\n* [x] Create base auth page\r\n* [x] Add sign in form in auth page (with AJAX request to API)\r\n* [x] Add sign up form in auth page (with AJAX request to API)\r\n* [x] Store user info (username, role, lang) in local storage\r\n* [x] Show username when authenticated\r\n* [x] Add sign out button when authenticated\r\n* [x] Use consistent routes/URLs name with API: register/login/logout\r\n* [ ] Show errors if login or register failed\r\n* [ ] \"Remind me\" checkbox \r\n* [ ] Whitelist login/register requests\r\n* [x] Redirect to original page after login\r\n* [x] Show register form only on request","created_at":"2015-11-25T15:04:48Z","updated_at":"2015-12-02T10:47:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"881db92afe01e8dc477f73bba8d5583b1a1dc38f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/36/commits","review_comments_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/36/comments","review_comment_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/issues/36/comments","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/d3f9e9c4d603ec5035d3a5f10c4fccaffe4f83c7","head":{"label":"c2corg:auth","ref":"auth","sha":"d3f9e9c4d603ec5035d3a5f10c4fccaffe4f83c7","user":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"repo":{"id":43445823,"name":"v6_ui","full_name":"c2corg/v6_ui","owner":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c2corg/v6_ui","description":"UI for c2c.org v6","fork":false,"url":"https://api.github.com/repos/c2corg/v6_ui","forks_url":"https://api.github.com/repos/c2corg/v6_ui/forks","keys_url":"https://api.github.com/repos/c2corg/v6_ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c2corg/v6_ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c2corg/v6_ui/teams","hooks_url":"https://api.github.com/repos/c2corg/v6_ui/hooks","issue_events_url":"https://api.github.com/repos/c2corg/v6_ui/issues/events{/number}","events_url":"https://api.github.com/repos/c2corg/v6_ui/events","assignees_url":"https://api.github.com/repos/c2corg/v6_ui/assignees{/user}","branches_url":"https://api.github.com/repos/c2corg/v6_ui/branches{/branch}","tags_url":"https://api.github.com/repos/c2corg/v6_ui/tags","blobs_url":"https://api.github.com/repos/c2corg/v6_ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c2corg/v6_ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c2corg/v6_ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/c2corg/v6_ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/{sha}","languages_url":"https://api.github.com/repos/c2corg/v6_ui/languages","stargazers_url":"https://api.github.com/repos/c2corg/v6_ui/stargazers","contributors_url":"https://api.github.com/repos/c2corg/v6_ui/contributors","subscribers_url":"https://api.github.com/repos/c2corg/v6_ui/subscribers","subscription_url":"https://api.github.com/repos/c2corg/v6_ui/subscription","commits_url":"https://api.github.com/repos/c2corg/v6_ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/c2corg/v6_ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/c2corg/v6_ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/c2corg/v6_ui/contents/{+path}","compare_url":"https://api.github.com/repos/c2corg/v6_ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c2corg/v6_ui/merges","archive_url":"https://api.github.com/repos/c2corg/v6_ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c2corg/v6_ui/downloads","issues_url":"https://api.github.com/repos/c2corg/v6_ui/issues{/number}","pulls_url":"https://api.github.com/repos/c2corg/v6_ui/pulls{/number}","milestones_url":"https://api.github.com/repos/c2corg/v6_ui/milestones{/number}","notifications_url":"https://api.github.com/repos/c2corg/v6_ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c2corg/v6_ui/labels{/name}","releases_url":"https://api.github.com/repos/c2corg/v6_ui/releases{/id}","created_at":"2015-09-30T16:52:44Z","updated_at":"2015-10-29T12:35:02Z","pushed_at":"2015-12-02T09:42:31Z","git_url":"git://github.com/c2corg/v6_ui.git","ssh_url":"git@github.com:c2corg/v6_ui.git","clone_url":"https://github.com/c2corg/v6_ui.git","svn_url":"https://github.com/c2corg/v6_ui","homepage":null,"size":193,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":21,"forks":0,"open_issues":21,"watchers":0,"default_branch":"master"}},"base":{"label":"c2corg:master","ref":"master","sha":"5fed4c75ccb3fa48aa04b580490345b8ecd6f9f6","user":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"repo":{"id":43445823,"name":"v6_ui","full_name":"c2corg/v6_ui","owner":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c2corg/v6_ui","description":"UI for c2c.org v6","fork":false,"url":"https://api.github.com/repos/c2corg/v6_ui","forks_url":"https://api.github.com/repos/c2corg/v6_ui/forks","keys_url":"https://api.github.com/repos/c2corg/v6_ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c2corg/v6_ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c2corg/v6_ui/teams","hooks_url":"https://api.github.com/repos/c2corg/v6_ui/hooks","issue_events_url":"https://api.github.com/repos/c2corg/v6_ui/issues/events{/number}","events_url":"https://api.github.com/repos/c2corg/v6_ui/events","assignees_url":"https://api.github.com/repos/c2corg/v6_ui/assignees{/user}","branches_url":"https://api.github.com/repos/c2corg/v6_ui/branches{/branch}","tags_url":"https://api.github.com/repos/c2corg/v6_ui/tags","blobs_url":"https://api.github.com/repos/c2corg/v6_ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c2corg/v6_ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c2corg/v6_ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/c2corg/v6_ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/{sha}","languages_url":"https://api.github.com/repos/c2corg/v6_ui/languages","stargazers_url":"https://api.github.com/repos/c2corg/v6_ui/stargazers","contributors_url":"https://api.github.com/repos/c2corg/v6_ui/contributors","subscribers_url":"https://api.github.com/repos/c2corg/v6_ui/subscribers","subscription_url":"https://api.github.com/repos/c2corg/v6_ui/subscription","commits_url":"https://api.github.com/repos/c2corg/v6_ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/c2corg/v6_ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/c2corg/v6_ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/c2corg/v6_ui/contents/{+path}","compare_url":"https://api.github.com/repos/c2corg/v6_ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c2corg/v6_ui/merges","archive_url":"https://api.github.com/repos/c2corg/v6_ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c2corg/v6_ui/downloads","issues_url":"https://api.github.com/repos/c2corg/v6_ui/issues{/number}","pulls_url":"https://api.github.com/repos/c2corg/v6_ui/pulls{/number}","milestones_url":"https://api.github.com/repos/c2corg/v6_ui/milestones{/number}","notifications_url":"https://api.github.com/repos/c2corg/v6_ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c2corg/v6_ui/labels{/name}","releases_url":"https://api.github.com/repos/c2corg/v6_ui/releases{/id}","created_at":"2015-09-30T16:52:44Z","updated_at":"2015-10-29T12:35:02Z","pushed_at":"2015-12-02T09:42:31Z","git_url":"git://github.com/c2corg/v6_ui.git","ssh_url":"git@github.com:c2corg/v6_ui.git","clone_url":"https://github.com/c2corg/v6_ui.git","svn_url":"https://github.com/c2corg/v6_ui","homepage":null,"size":193,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":21,"forks":0,"open_issues":21,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/36"},"html":{"href":"https://github.com/c2corg/v6_ui/pull/36"},"issue":{"href":"https://api.github.com/repos/c2corg/v6_ui/issues/36"},"comments":{"href":"https://api.github.com/repos/c2corg/v6_ui/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/c2corg/v6_ui/statuses/d3f9e9c4d603ec5035d3a5f10c4fccaffe4f83c7"}}}}