Search code examples
facebookoauthionic-frameworkfirebase-authenticationfacebook-authentication

How to ask for new user credentials - Ionic & Firebase


I am currently using AngularFire's $authWithOAuthPopup method. On Logout, the Firebase session is ended, but the OAuth persists (as per intended functionality). link Link Explaining oAuth is separate workflow from app logout

However, if this happens, the $authWithOAuthPopup does not allow for another user to input credentials on re-login.

Have people found success in implementing a solution which allows for someone else to login? How would someone allow for a new user to input new login credentials as opposed to automatically using the old information?

Current behavior: Log user out > click login > app uses previous FB session's information to login. Wanted behavior: Log user out > click login > asks for user's FB credentials > login.

$scope.logout = function () {
  delete $localStorage.storageAuth;
  Auth.$unauth();
  $state.go('user.signin');
};

Thanks :)


Solution

  • original answer in ionic forum https://forum.ionicframework.com/t/facebook-logout-with-firebase-ionic-clear-oauth-session-so-new-user-can-login/54557/2?u=aaronksaunders

    can we see the login/auth code... what are you doing with$localStorage.storageAuth you really shouldn't need it for firebase since it will manage the the user's login state for you... I believe...

    but you can try and clear the cookies/session information
    
    // _blank loads in background, might need clearsessioncache
    var ref = window.open(url, '_blank', 'location=no,toolbar=no,clearcache=yes');
    
    // attach a listener to the window which closes it when complete
    ref.addEventListener('loadstop', function(event) { 
        ref.close();
    });
    

    See documentation https://github.com/apache/cordova-plugin-inappbrowser1