{"action":"created","issue":{"url":"https://api.github.com/repos/koajs/userauth/issues/14","labels_url":"https://api.github.com/repos/koajs/userauth/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/koajs/userauth/issues/14/comments","events_url":"https://api.github.com/repos/koajs/userauth/issues/14/events","html_url":"https://github.com/koajs/userauth/issues/14","id":121669160,"number":14,"title":"有循环重定向的可能","user":{"login":"huqingliang","id":4279184,"avatar_url":"https://avatars.githubusercontent.com/u/4279184?v=3","gravatar_id":"","url":"https://api.github.com/users/huqingliang","html_url":"https://github.com/huqingliang","followers_url":"https://api.github.com/users/huqingliang/followers","following_url":"https://api.github.com/users/huqingliang/following{/other_user}","gists_url":"https://api.github.com/users/huqingliang/gists{/gist_id}","starred_url":"https://api.github.com/users/huqingliang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huqingliang/subscriptions","organizations_url":"https://api.github.com/users/huqingliang/orgs","repos_url":"https://api.github.com/users/huqingliang/repos","events_url":"https://api.github.com/users/huqingliang/events{/privacy}","received_events_url":"https://api.github.com/users/huqingliang/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-11T09:23:14Z","updated_at":"2015-12-11T09:38:55Z","closed_at":null,"body":"```\r\nif (!this.session) {\r\n      debug('this.session not exists');\r\n      // ignore not match path\r\n      if (!loginRequired) {\r\n        debug('not match needLogin path, %j', this.path);\r\n        return yield next;\r\n      }\r\n      debug('relogin again');\r\n      return yield loginHandler.call(this, next);\r\n    }\r\n\r\n    // get login path\r\n    if (this.path === options.loginPath) {\r\n      debug('match login path');\r\n      return yield loginHandler.call(this, next);\r\n    }\r\n```\r\n场景：\r\n当\r\nloginPath=/login\r\nloginHost=demo.xxx.com\r\n浏览器中输入demo.xxx.com/login （带有部分cookie），这是就能跳过第一个判断if (!this.session) \r\n而 if (this.path === options.loginPath) 符合条件！\r\n最终就会执行到loginHandler 的 redirect(this, loginURL);\r\n@fengmk2 "},"comment":{"url":"https://api.github.com/repos/koajs/userauth/issues/comments/163888174","html_url":"https://github.com/koajs/userauth/issues/14#issuecomment-163888174","issue_url":"https://api.github.com/repos/koajs/userauth/issues/14","id":163888174,"user":{"login":"huqingliang","id":4279184,"avatar_url":"https://avatars.githubusercontent.com/u/4279184?v=3","gravatar_id":"","url":"https://api.github.com/users/huqingliang","html_url":"https://github.com/huqingliang","followers_url":"https://api.github.com/users/huqingliang/followers","following_url":"https://api.github.com/users/huqingliang/following{/other_user}","gists_url":"https://api.github.com/users/huqingliang/gists{/gist_id}","starred_url":"https://api.github.com/users/huqingliang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huqingliang/subscriptions","organizations_url":"https://api.github.com/users/huqingliang/orgs","repos_url":"https://api.github.com/users/huqingliang/repos","events_url":"https://api.github.com/users/huqingliang/events{/privacy}","received_events_url":"https://api.github.com/users/huqingliang/received_events","type":"User","site_admin":false},"created_at":"2015-12-11T09:38:55Z","updated_at":"2015-12-11T09:38:55Z","body":"或者这样？\r\n```\r\nif (!this.session) \r\nto\r\nif (!this.session[options.userField])\r\n```"}}