{"action":"opened","issue":{"url":"https://api.github.com/repos/prescottprue/react-redux-firebase/issues/531","repository_url":"https://api.github.com/repos/prescottprue/react-redux-firebase","labels_url":"https://api.github.com/repos/prescottprue/react-redux-firebase/issues/531/labels{/name}","comments_url":"https://api.github.com/repos/prescottprue/react-redux-firebase/issues/531/comments","events_url":"https://api.github.com/repos/prescottprue/react-redux-firebase/issues/531/events","html_url":"https://github.com/prescottprue/react-redux-firebase/issues/531","id":356293171,"node_id":"MDU6SXNzdWUzNTYyOTMxNzE=","number":531,"title":"How to integrate auth custom claims in routing?","user":{"login":"0x80","id":1193520,"node_id":"MDQ6VXNlcjExOTM1MjA=","avatar_url":"https://avatars1.githubusercontent.com/u/1193520?v=4","gravatar_id":"","url":"https://api.github.com/users/0x80","html_url":"https://github.com/0x80","followers_url":"https://api.github.com/users/0x80/followers","following_url":"https://api.github.com/users/0x80/following{/other_user}","gists_url":"https://api.github.com/users/0x80/gists{/gist_id}","starred_url":"https://api.github.com/users/0x80/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0x80/subscriptions","organizations_url":"https://api.github.com/users/0x80/orgs","repos_url":"https://api.github.com/users/0x80/repos","events_url":"https://api.github.com/users/0x80/events{/privacy}","received_events_url":"https://api.github.com/users/0x80/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-09-02T15:56:10Z","updated_at":"2018-09-02T15:56:10Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Hi,\r\n\r\nI would like to use firebase auth custom claims to validate if a user is allowed to access the current route (and redirect if not). \r\n\r\nI am having a hard time trying to figure out where to put this logic in the flow. Currently I'm using the firebaseAuthIsReady callback:\r\n\r\n```\r\nstore.firebaseAuthIsReady.then(async () => {\r\n    console.log(\"Auth has loaded\");\r\n\r\n    const user = firebase.auth().currentUser;\r\n\r\n    if (!user) {\r\n      console.log(\"no user\");\r\n      return;\r\n    }\r\n    const idTokenResult = await user.getIdTokenResult();\r\n\r\n    console.log(\"claims\", idTokenResult.claims);\r\n\r\n    if (idTokenResult.claims.admin === true) {\r\n      console.log(\"ADMIN USER\");\r\n\r\n      // store this so that route component can access\r\n      window.isAdminUser = true;\r\n    } else {\r\n      console.log(\"NOT ADMIN USER\");\r\n\r\n      // store this so that route component can access\r\n      window.isAdminUser = false;\r\n    }\r\n  });\r\n```\r\n\r\nBesides that if feels wrong to store this boolean on the window object, it also seems too late for the rendering routes to pick this up and redirect when they are instantiated.\r\n\r\nDo you have an idea where I'm going wrong? Can I store this variable in the store so the routes can listen to it?"}}
{"actor":{"display_login":"0x80"}}