{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angularfire2/issues/1459","repository_url":"https://api.github.com/repos/angular/angularfire2","labels_url":"https://api.github.com/repos/angular/angularfire2/issues/1459/labels{/name}","comments_url":"https://api.github.com/repos/angular/angularfire2/issues/1459/comments","events_url":"https://api.github.com/repos/angular/angularfire2/issues/1459/events","html_url":"https://github.com/angular/angularfire2/issues/1459","id":294938799,"number":1459,"title":"angularfire2 - firestore: Missing or insufficient permissions on logout","user":{"login":"chensifeng","id":671617,"avatar_url":"https://avatars0.githubusercontent.com/u/671617?v=4","gravatar_id":"","url":"https://api.github.com/users/chensifeng","html_url":"https://github.com/chensifeng","followers_url":"https://api.github.com/users/chensifeng/followers","following_url":"https://api.github.com/users/chensifeng/following{/other_user}","gists_url":"https://api.github.com/users/chensifeng/gists{/gist_id}","starred_url":"https://api.github.com/users/chensifeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chensifeng/subscriptions","organizations_url":"https://api.github.com/users/chensifeng/orgs","repos_url":"https://api.github.com/users/chensifeng/repos","events_url":"https://api.github.com/users/chensifeng/events{/privacy}","received_events_url":"https://api.github.com/users/chensifeng/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-02-06T22:38:29Z","updated_at":"2018-05-14T16:17:46Z","closed_at":"2018-05-04T21:07:50Z","author_association":"NONE","body":"<!--\r\n\r\nIMPORTANT! YOU MUST FOLLOW THESE INSTRUCTIONS OR YOUR ISSUE WILL BE CLOSED.\r\n\r\nThank you for contributing to the Angular and Firebase communities!\r\n\r\nHave a usage question?\r\n=======================\r\nWe get lots of those and we love helping you, but GitHub is not the best place for them and they will be closed. Here are some resources to get help:\r\n\r\n- Go through the Developer's Guide: https://github.com/angular/angularfire2#developer-guide\r\n\r\nIf the official documentation doesn't help, try asking through our officially supported channels:\r\n\r\n- Firebase Google Group: https://groups.google.com/forum/#!forum/firebase-talk\r\n- Stack Overflow: https://stackoverflow.com/questions/tagged/angular (include the firebase and angularfire tags, too!)\r\n\r\n*Please avoid double posting across multiple channels!*\r\n\r\nThink you found a bug?\r\n=======================\r\nYeah, we're definitely not perfect! Please use the bug report template below and include a minimal repro when opening the issue.\r\n\r\nHave a feature request?\r\n========================\r\nGreat, we love hearing how we can improve our products! Remove the template below and\r\nprovide an explanation of your feature request. Provide code samples if applicable. Try to\r\nthink about what it will allow you to do that you can't do today? How will it make current\r\nworkarounds straightforward? What potential bugs and edge cases does it help to avoid?\r\n\r\n-->\r\n\r\n\r\n### Version info\r\n\r\n<!-- What versions of the following libraries are you using? Note that your issue may already\r\nbe fixed in the latest versions. -->\r\n\r\n**Angular:** 4.4.4\r\n\r\n**Firebase:** 4.8.2\r\n\r\n**AngularFire:** ^5.0.0-rc.4\r\n\r\n**Other (e.g. Ionic/Cordova, Node, browser, operating system):** browser, macbook\r\n\r\n### How to reproduce these conditions\r\n\r\nI had the same issue for weeks which was written in StackOverflow: https://stackoverflow.com/questions/46831468/ionic2-angularfire2-firestore-missing-or-insufficient-permissions-on-logout\r\n\r\nMaybe i forget to clean up cache or remove something?\r\n\r\nCould someone please help me out? \r\nThanks in advance!"},"comment":{"url":"https://api.github.com/repos/angular/angularfire2/issues/comments/388875659","html_url":"https://github.com/angular/angularfire2/issues/1459#issuecomment-388875659","issue_url":"https://api.github.com/repos/angular/angularfire2/issues/1459","id":388875659,"user":{"login":"rwmb","id":20707521,"avatar_url":"https://avatars3.githubusercontent.com/u/20707521?v=4","gravatar_id":"","url":"https://api.github.com/users/rwmb","html_url":"https://github.com/rwmb","followers_url":"https://api.github.com/users/rwmb/followers","following_url":"https://api.github.com/users/rwmb/following{/other_user}","gists_url":"https://api.github.com/users/rwmb/gists{/gist_id}","starred_url":"https://api.github.com/users/rwmb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwmb/subscriptions","organizations_url":"https://api.github.com/users/rwmb/orgs","repos_url":"https://api.github.com/users/rwmb/repos","events_url":"https://api.github.com/users/rwmb/events{/privacy}","received_events_url":"https://api.github.com/users/rwmb/received_events","type":"User","site_admin":false},"created_at":"2018-05-14T16:17:46Z","updated_at":"2018-05-14T16:17:46Z","author_association":"NONE","body":"Here's what I did to solve this problem: I wrapped the `authState` in a BehaviourSubject (it's possible to use a ReplaySubject as well, or a simple Subject I guess) like this:\r\n```\r\nthis.afAuth\r\n      .authState\r\n      .subscribe((data) => {\r\n        if (!this.$logged) {\r\n          this.$logged = new BehaviorSubject<any>(data);\r\n          this.user.initialize(this.$logged);\r\n        } else {\r\n          this.$logged.next(data);\r\n        }\r\n      });\r\n```\r\nand to fix the problem I use this `$logged` subject instead, because I can easily send `null` from this one upon sign out.\r\n```\r\nsignOut() {\r\n    this.afAuth\r\n      .auth\r\n      .signOut()\r\n      .then(() => {\r\n        console.log('signout');\r\n        this.$logged.next(null);\r\n        this.router.navigate(['/']);\r\n      });\r\n  }\r\n```\r\nI know there's a better way to implement this, maybe extending the afAuth and using our own auth handler, but since I wanted to control the user initialization I did it this way.\r\nI appreciate suggestions on improvements and hope this helps."}}
{"actor":{"display_login":"rwmb"}}