How to force logout firebase auth user from app remotely









up vote
7
down vote

favorite
3












I have a project which uses firebase auth with firebaseUI to authenticate users. I have enabled Google, Facebook and email providers. What I need is to remotely logout or disable some of the users.



I want the users to logout from the app on doing so. I tried disabling the user in the firebase console and also used the firebase admin SDK (https://firebase.google.com/docs/auth/admin/manage-sessions) to revoke the refresh tokens.



I waited for more than 2 days and still noticed that the user was logged in and could access the firestore data.



I have also gone through and tried
Firebase still retrieving authData after deletion



Can anyone point to what I am doing wrong ?










share|improve this question



























    up vote
    7
    down vote

    favorite
    3












    I have a project which uses firebase auth with firebaseUI to authenticate users. I have enabled Google, Facebook and email providers. What I need is to remotely logout or disable some of the users.



    I want the users to logout from the app on doing so. I tried disabling the user in the firebase console and also used the firebase admin SDK (https://firebase.google.com/docs/auth/admin/manage-sessions) to revoke the refresh tokens.



    I waited for more than 2 days and still noticed that the user was logged in and could access the firestore data.



    I have also gone through and tried
    Firebase still retrieving authData after deletion



    Can anyone point to what I am doing wrong ?










    share|improve this question

























      up vote
      7
      down vote

      favorite
      3









      up vote
      7
      down vote

      favorite
      3






      3





      I have a project which uses firebase auth with firebaseUI to authenticate users. I have enabled Google, Facebook and email providers. What I need is to remotely logout or disable some of the users.



      I want the users to logout from the app on doing so. I tried disabling the user in the firebase console and also used the firebase admin SDK (https://firebase.google.com/docs/auth/admin/manage-sessions) to revoke the refresh tokens.



      I waited for more than 2 days and still noticed that the user was logged in and could access the firestore data.



      I have also gone through and tried
      Firebase still retrieving authData after deletion



      Can anyone point to what I am doing wrong ?










      share|improve this question















      I have a project which uses firebase auth with firebaseUI to authenticate users. I have enabled Google, Facebook and email providers. What I need is to remotely logout or disable some of the users.



      I want the users to logout from the app on doing so. I tried disabling the user in the firebase console and also used the firebase admin SDK (https://firebase.google.com/docs/auth/admin/manage-sessions) to revoke the refresh tokens.



      I waited for more than 2 days and still noticed that the user was logged in and could access the firestore data.



      I have also gone through and tried
      Firebase still retrieving authData after deletion



      Can anyone point to what I am doing wrong ?







      firebase firebase-authentication firebase-admin






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 at 2:40









      esarkis

      838




      838










      asked Oct 31 at 16:19









      Ashwin Valento

      1066




      1066






















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          3
          down vote













          You can send a message data with FCM to force to log out.



          For example, if the users use android application.



          1. Save the FCM token in a collection in firebase Realtime.

          2. configure the Android client app, in the service. LINK You have to make when receive a message with especial string, force to log out.

          3. make the trigger you need in cloud functions, to send the data LINK when you need the user log out.

          SUCCESS!






          share|improve this answer



























            up vote
            3
            down vote



            +25










            You also cannot remotely force a user to be signed out. Any sign out will have to happen from the device that the user is signed in on.



            There is no way to revoke an access token once that is minted. This means that even if you disable the user's account, they may continue to have access for up to an hour.



            If that is too long, the trick (as also mentioned in my answer to the question you linked) is to maintain a list of blocked users in your database (or elsewhere) and then check against that in your security rules (or other authorization layer).



            For example in the realtime database, you could create a list of blocked user's UIDs:



            banned_uids
            uid1: true
            uid2: true


            And then check against that in your security rules with:



            ".read": "auth.uid !== null && !root.child('banned_uids').child(auth.uid).exists()"





            share|improve this answer






















            • Thanks, @frank-van-puffelen. In our case, we tried disabling the user and tried revoking his/her refresh token, but the user is still able to access data even after waiting for 1 hour (we waited for 2 days also :) ). We also have rule added in Firestore to allow only authenticated user. If my understanding is wrong, please help me understand when to revoke user refresh token?
              – Vishal Vijay
              Nov 10 at 10:38










            • I noticed I said ID token, where I mean access token, so I fixed that. Revoking access tokens isn't enough, so that's where security rules come in. If the steps don't work for you, show exactly what you've done. Without code or exact steps-to-reproduce, it is hard for anyone to say where you made a mistake.
              – Frank van Puffelen
              Nov 10 at 15:08

















            up vote
            2
            down vote













            As per your scenarios, i assume that you need to make user logout when user is disabled.



            Use One global variable to store TokenNo (might be in shared preference or sqlite):



            Add following code to your manifest:



            <service android:name=".YourFirebaseMessagingService">
            <intent-filter>
            <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
            </service>


            Add following code in your



            public class LogoutOntokenchange extends FirebaseMessagingService
            @Override
            public void onNewToken (String token)
            if(TokenNo=>1) //if tokenNo >=1 means he already logged in
            TokenNo=0;
            FirebaseAuth.getInstance().signOut(); //Then call signout method

            else
            TokenNo=1; //store token no in db





            What Happens here:


            When user logged in first time onNewToken is called then It goes into else then TokenNo is updated to 1 from 0.

            When You disable any user then automatically token is refreshed.Then OnNewToken is called then TokenNo>=1 so user will be logged out.


            NOTE: When user log in for first time i.e if TokenNo variable is not stored then store it as 0.



            For reference: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessagingService






            share|improve this answer






















            • As far as I know, onNewToken above belongs to FCM. Can you please explain why are we Logging the user out on refresh of FCM token ?
              – Ashwin Valento
              Nov 15 at 15:31

















            up vote
            0
            down vote













            Not tested yet, as our backend programmer, who is in charge of setting up Firestore rules was gone for the day, but in theory this should work: (and it's something I'll test tomorrow)



            Having a FirebaseAuth.AuthStateListener in charge of serving UI based on the status of the user



            This combined with rules in firestore



            match /collection
            allow read: if isAuth();


            Where isAuth is:



            function isAuth() 
            return request.auth.uid != null;



            If the user is then disabled, while being logged in, whenever the user tries to read data from the collection, he should be denied, and a signOut() call should be made.
            The AuthStateListener will then detect it, and sign the user out.






            share|improve this answer




















              Your Answer






              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "1"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53087895%2fhow-to-force-logout-firebase-auth-user-from-app-remotely%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              3
              down vote













              You can send a message data with FCM to force to log out.



              For example, if the users use android application.



              1. Save the FCM token in a collection in firebase Realtime.

              2. configure the Android client app, in the service. LINK You have to make when receive a message with especial string, force to log out.

              3. make the trigger you need in cloud functions, to send the data LINK when you need the user log out.

              SUCCESS!






              share|improve this answer
























                up vote
                3
                down vote













                You can send a message data with FCM to force to log out.



                For example, if the users use android application.



                1. Save the FCM token in a collection in firebase Realtime.

                2. configure the Android client app, in the service. LINK You have to make when receive a message with especial string, force to log out.

                3. make the trigger you need in cloud functions, to send the data LINK when you need the user log out.

                SUCCESS!






                share|improve this answer






















                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  You can send a message data with FCM to force to log out.



                  For example, if the users use android application.



                  1. Save the FCM token in a collection in firebase Realtime.

                  2. configure the Android client app, in the service. LINK You have to make when receive a message with especial string, force to log out.

                  3. make the trigger you need in cloud functions, to send the data LINK when you need the user log out.

                  SUCCESS!






                  share|improve this answer












                  You can send a message data with FCM to force to log out.



                  For example, if the users use android application.



                  1. Save the FCM token in a collection in firebase Realtime.

                  2. configure the Android client app, in the service. LINK You have to make when receive a message with especial string, force to log out.

                  3. make the trigger you need in cloud functions, to send the data LINK when you need the user log out.

                  SUCCESS!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 10 at 6:27









                  Mike Brian Olivera

                  3651513




                  3651513






















                      up vote
                      3
                      down vote



                      +25










                      You also cannot remotely force a user to be signed out. Any sign out will have to happen from the device that the user is signed in on.



                      There is no way to revoke an access token once that is minted. This means that even if you disable the user's account, they may continue to have access for up to an hour.



                      If that is too long, the trick (as also mentioned in my answer to the question you linked) is to maintain a list of blocked users in your database (or elsewhere) and then check against that in your security rules (or other authorization layer).



                      For example in the realtime database, you could create a list of blocked user's UIDs:



                      banned_uids
                      uid1: true
                      uid2: true


                      And then check against that in your security rules with:



                      ".read": "auth.uid !== null && !root.child('banned_uids').child(auth.uid).exists()"





                      share|improve this answer






















                      • Thanks, @frank-van-puffelen. In our case, we tried disabling the user and tried revoking his/her refresh token, but the user is still able to access data even after waiting for 1 hour (we waited for 2 days also :) ). We also have rule added in Firestore to allow only authenticated user. If my understanding is wrong, please help me understand when to revoke user refresh token?
                        – Vishal Vijay
                        Nov 10 at 10:38










                      • I noticed I said ID token, where I mean access token, so I fixed that. Revoking access tokens isn't enough, so that's where security rules come in. If the steps don't work for you, show exactly what you've done. Without code or exact steps-to-reproduce, it is hard for anyone to say where you made a mistake.
                        – Frank van Puffelen
                        Nov 10 at 15:08














                      up vote
                      3
                      down vote



                      +25










                      You also cannot remotely force a user to be signed out. Any sign out will have to happen from the device that the user is signed in on.



                      There is no way to revoke an access token once that is minted. This means that even if you disable the user's account, they may continue to have access for up to an hour.



                      If that is too long, the trick (as also mentioned in my answer to the question you linked) is to maintain a list of blocked users in your database (or elsewhere) and then check against that in your security rules (or other authorization layer).



                      For example in the realtime database, you could create a list of blocked user's UIDs:



                      banned_uids
                      uid1: true
                      uid2: true


                      And then check against that in your security rules with:



                      ".read": "auth.uid !== null && !root.child('banned_uids').child(auth.uid).exists()"





                      share|improve this answer






















                      • Thanks, @frank-van-puffelen. In our case, we tried disabling the user and tried revoking his/her refresh token, but the user is still able to access data even after waiting for 1 hour (we waited for 2 days also :) ). We also have rule added in Firestore to allow only authenticated user. If my understanding is wrong, please help me understand when to revoke user refresh token?
                        – Vishal Vijay
                        Nov 10 at 10:38










                      • I noticed I said ID token, where I mean access token, so I fixed that. Revoking access tokens isn't enough, so that's where security rules come in. If the steps don't work for you, show exactly what you've done. Without code or exact steps-to-reproduce, it is hard for anyone to say where you made a mistake.
                        – Frank van Puffelen
                        Nov 10 at 15:08












                      up vote
                      3
                      down vote



                      +25







                      up vote
                      3
                      down vote



                      +25




                      +25




                      You also cannot remotely force a user to be signed out. Any sign out will have to happen from the device that the user is signed in on.



                      There is no way to revoke an access token once that is minted. This means that even if you disable the user's account, they may continue to have access for up to an hour.



                      If that is too long, the trick (as also mentioned in my answer to the question you linked) is to maintain a list of blocked users in your database (or elsewhere) and then check against that in your security rules (or other authorization layer).



                      For example in the realtime database, you could create a list of blocked user's UIDs:



                      banned_uids
                      uid1: true
                      uid2: true


                      And then check against that in your security rules with:



                      ".read": "auth.uid !== null && !root.child('banned_uids').child(auth.uid).exists()"





                      share|improve this answer














                      You also cannot remotely force a user to be signed out. Any sign out will have to happen from the device that the user is signed in on.



                      There is no way to revoke an access token once that is minted. This means that even if you disable the user's account, they may continue to have access for up to an hour.



                      If that is too long, the trick (as also mentioned in my answer to the question you linked) is to maintain a list of blocked users in your database (or elsewhere) and then check against that in your security rules (or other authorization layer).



                      For example in the realtime database, you could create a list of blocked user's UIDs:



                      banned_uids
                      uid1: true
                      uid2: true


                      And then check against that in your security rules with:



                      ".read": "auth.uid !== null && !root.child('banned_uids').child(auth.uid).exists()"






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 10 at 15:08

























                      answered Nov 9 at 22:22









                      Frank van Puffelen

                      220k25361387




                      220k25361387











                      • Thanks, @frank-van-puffelen. In our case, we tried disabling the user and tried revoking his/her refresh token, but the user is still able to access data even after waiting for 1 hour (we waited for 2 days also :) ). We also have rule added in Firestore to allow only authenticated user. If my understanding is wrong, please help me understand when to revoke user refresh token?
                        – Vishal Vijay
                        Nov 10 at 10:38










                      • I noticed I said ID token, where I mean access token, so I fixed that. Revoking access tokens isn't enough, so that's where security rules come in. If the steps don't work for you, show exactly what you've done. Without code or exact steps-to-reproduce, it is hard for anyone to say where you made a mistake.
                        – Frank van Puffelen
                        Nov 10 at 15:08
















                      • Thanks, @frank-van-puffelen. In our case, we tried disabling the user and tried revoking his/her refresh token, but the user is still able to access data even after waiting for 1 hour (we waited for 2 days also :) ). We also have rule added in Firestore to allow only authenticated user. If my understanding is wrong, please help me understand when to revoke user refresh token?
                        – Vishal Vijay
                        Nov 10 at 10:38










                      • I noticed I said ID token, where I mean access token, so I fixed that. Revoking access tokens isn't enough, so that's where security rules come in. If the steps don't work for you, show exactly what you've done. Without code or exact steps-to-reproduce, it is hard for anyone to say where you made a mistake.
                        – Frank van Puffelen
                        Nov 10 at 15:08















                      Thanks, @frank-van-puffelen. In our case, we tried disabling the user and tried revoking his/her refresh token, but the user is still able to access data even after waiting for 1 hour (we waited for 2 days also :) ). We also have rule added in Firestore to allow only authenticated user. If my understanding is wrong, please help me understand when to revoke user refresh token?
                      – Vishal Vijay
                      Nov 10 at 10:38




                      Thanks, @frank-van-puffelen. In our case, we tried disabling the user and tried revoking his/her refresh token, but the user is still able to access data even after waiting for 1 hour (we waited for 2 days also :) ). We also have rule added in Firestore to allow only authenticated user. If my understanding is wrong, please help me understand when to revoke user refresh token?
                      – Vishal Vijay
                      Nov 10 at 10:38












                      I noticed I said ID token, where I mean access token, so I fixed that. Revoking access tokens isn't enough, so that's where security rules come in. If the steps don't work for you, show exactly what you've done. Without code or exact steps-to-reproduce, it is hard for anyone to say where you made a mistake.
                      – Frank van Puffelen
                      Nov 10 at 15:08




                      I noticed I said ID token, where I mean access token, so I fixed that. Revoking access tokens isn't enough, so that's where security rules come in. If the steps don't work for you, show exactly what you've done. Without code or exact steps-to-reproduce, it is hard for anyone to say where you made a mistake.
                      – Frank van Puffelen
                      Nov 10 at 15:08










                      up vote
                      2
                      down vote













                      As per your scenarios, i assume that you need to make user logout when user is disabled.



                      Use One global variable to store TokenNo (might be in shared preference or sqlite):



                      Add following code to your manifest:



                      <service android:name=".YourFirebaseMessagingService">
                      <intent-filter>
                      <action android:name="com.google.firebase.MESSAGING_EVENT" />
                      </intent-filter>
                      </service>


                      Add following code in your



                      public class LogoutOntokenchange extends FirebaseMessagingService
                      @Override
                      public void onNewToken (String token)
                      if(TokenNo=>1) //if tokenNo >=1 means he already logged in
                      TokenNo=0;
                      FirebaseAuth.getInstance().signOut(); //Then call signout method

                      else
                      TokenNo=1; //store token no in db





                      What Happens here:


                      When user logged in first time onNewToken is called then It goes into else then TokenNo is updated to 1 from 0.

                      When You disable any user then automatically token is refreshed.Then OnNewToken is called then TokenNo>=1 so user will be logged out.


                      NOTE: When user log in for first time i.e if TokenNo variable is not stored then store it as 0.



                      For reference: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessagingService






                      share|improve this answer






















                      • As far as I know, onNewToken above belongs to FCM. Can you please explain why are we Logging the user out on refresh of FCM token ?
                        – Ashwin Valento
                        Nov 15 at 15:31














                      up vote
                      2
                      down vote













                      As per your scenarios, i assume that you need to make user logout when user is disabled.



                      Use One global variable to store TokenNo (might be in shared preference or sqlite):



                      Add following code to your manifest:



                      <service android:name=".YourFirebaseMessagingService">
                      <intent-filter>
                      <action android:name="com.google.firebase.MESSAGING_EVENT" />
                      </intent-filter>
                      </service>


                      Add following code in your



                      public class LogoutOntokenchange extends FirebaseMessagingService
                      @Override
                      public void onNewToken (String token)
                      if(TokenNo=>1) //if tokenNo >=1 means he already logged in
                      TokenNo=0;
                      FirebaseAuth.getInstance().signOut(); //Then call signout method

                      else
                      TokenNo=1; //store token no in db





                      What Happens here:


                      When user logged in first time onNewToken is called then It goes into else then TokenNo is updated to 1 from 0.

                      When You disable any user then automatically token is refreshed.Then OnNewToken is called then TokenNo>=1 so user will be logged out.


                      NOTE: When user log in for first time i.e if TokenNo variable is not stored then store it as 0.



                      For reference: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessagingService






                      share|improve this answer






















                      • As far as I know, onNewToken above belongs to FCM. Can you please explain why are we Logging the user out on refresh of FCM token ?
                        – Ashwin Valento
                        Nov 15 at 15:31












                      up vote
                      2
                      down vote










                      up vote
                      2
                      down vote









                      As per your scenarios, i assume that you need to make user logout when user is disabled.



                      Use One global variable to store TokenNo (might be in shared preference or sqlite):



                      Add following code to your manifest:



                      <service android:name=".YourFirebaseMessagingService">
                      <intent-filter>
                      <action android:name="com.google.firebase.MESSAGING_EVENT" />
                      </intent-filter>
                      </service>


                      Add following code in your



                      public class LogoutOntokenchange extends FirebaseMessagingService
                      @Override
                      public void onNewToken (String token)
                      if(TokenNo=>1) //if tokenNo >=1 means he already logged in
                      TokenNo=0;
                      FirebaseAuth.getInstance().signOut(); //Then call signout method

                      else
                      TokenNo=1; //store token no in db





                      What Happens here:


                      When user logged in first time onNewToken is called then It goes into else then TokenNo is updated to 1 from 0.

                      When You disable any user then automatically token is refreshed.Then OnNewToken is called then TokenNo>=1 so user will be logged out.


                      NOTE: When user log in for first time i.e if TokenNo variable is not stored then store it as 0.



                      For reference: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessagingService






                      share|improve this answer














                      As per your scenarios, i assume that you need to make user logout when user is disabled.



                      Use One global variable to store TokenNo (might be in shared preference or sqlite):



                      Add following code to your manifest:



                      <service android:name=".YourFirebaseMessagingService">
                      <intent-filter>
                      <action android:name="com.google.firebase.MESSAGING_EVENT" />
                      </intent-filter>
                      </service>


                      Add following code in your



                      public class LogoutOntokenchange extends FirebaseMessagingService
                      @Override
                      public void onNewToken (String token)
                      if(TokenNo=>1) //if tokenNo >=1 means he already logged in
                      TokenNo=0;
                      FirebaseAuth.getInstance().signOut(); //Then call signout method

                      else
                      TokenNo=1; //store token no in db





                      What Happens here:


                      When user logged in first time onNewToken is called then It goes into else then TokenNo is updated to 1 from 0.

                      When You disable any user then automatically token is refreshed.Then OnNewToken is called then TokenNo>=1 so user will be logged out.


                      NOTE: When user log in for first time i.e if TokenNo variable is not stored then store it as 0.



                      For reference: https://firebase.google.com/docs/reference/android/com/google/firebase/messaging/FirebaseMessagingService







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 10 at 15:33

























                      answered Nov 10 at 15:28









                      maneesh

                      11312




                      11312











                      • As far as I know, onNewToken above belongs to FCM. Can you please explain why are we Logging the user out on refresh of FCM token ?
                        – Ashwin Valento
                        Nov 15 at 15:31
















                      • As far as I know, onNewToken above belongs to FCM. Can you please explain why are we Logging the user out on refresh of FCM token ?
                        – Ashwin Valento
                        Nov 15 at 15:31















                      As far as I know, onNewToken above belongs to FCM. Can you please explain why are we Logging the user out on refresh of FCM token ?
                      – Ashwin Valento
                      Nov 15 at 15:31




                      As far as I know, onNewToken above belongs to FCM. Can you please explain why are we Logging the user out on refresh of FCM token ?
                      – Ashwin Valento
                      Nov 15 at 15:31










                      up vote
                      0
                      down vote













                      Not tested yet, as our backend programmer, who is in charge of setting up Firestore rules was gone for the day, but in theory this should work: (and it's something I'll test tomorrow)



                      Having a FirebaseAuth.AuthStateListener in charge of serving UI based on the status of the user



                      This combined with rules in firestore



                      match /collection
                      allow read: if isAuth();


                      Where isAuth is:



                      function isAuth() 
                      return request.auth.uid != null;



                      If the user is then disabled, while being logged in, whenever the user tries to read data from the collection, he should be denied, and a signOut() call should be made.
                      The AuthStateListener will then detect it, and sign the user out.






                      share|improve this answer
























                        up vote
                        0
                        down vote













                        Not tested yet, as our backend programmer, who is in charge of setting up Firestore rules was gone for the day, but in theory this should work: (and it's something I'll test tomorrow)



                        Having a FirebaseAuth.AuthStateListener in charge of serving UI based on the status of the user



                        This combined with rules in firestore



                        match /collection
                        allow read: if isAuth();


                        Where isAuth is:



                        function isAuth() 
                        return request.auth.uid != null;



                        If the user is then disabled, while being logged in, whenever the user tries to read data from the collection, he should be denied, and a signOut() call should be made.
                        The AuthStateListener will then detect it, and sign the user out.






                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          Not tested yet, as our backend programmer, who is in charge of setting up Firestore rules was gone for the day, but in theory this should work: (and it's something I'll test tomorrow)



                          Having a FirebaseAuth.AuthStateListener in charge of serving UI based on the status of the user



                          This combined with rules in firestore



                          match /collection
                          allow read: if isAuth();


                          Where isAuth is:



                          function isAuth() 
                          return request.auth.uid != null;



                          If the user is then disabled, while being logged in, whenever the user tries to read data from the collection, he should be denied, and a signOut() call should be made.
                          The AuthStateListener will then detect it, and sign the user out.






                          share|improve this answer












                          Not tested yet, as our backend programmer, who is in charge of setting up Firestore rules was gone for the day, but in theory this should work: (and it's something I'll test tomorrow)



                          Having a FirebaseAuth.AuthStateListener in charge of serving UI based on the status of the user



                          This combined with rules in firestore



                          match /collection
                          allow read: if isAuth();


                          Where isAuth is:



                          function isAuth() 
                          return request.auth.uid != null;



                          If the user is then disabled, while being logged in, whenever the user tries to read data from the collection, he should be denied, and a signOut() call should be made.
                          The AuthStateListener will then detect it, and sign the user out.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 15 at 15:53









                          AverageJoeDK

                          1




                          1



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53087895%2fhow-to-force-logout-firebase-auth-user-from-app-remotely%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                              Edmonton

                              Crossroads (UK TV series)