0

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 :)

Community
  • 1
  • 1
njho
  • 2,023
  • 4
  • 22
  • 37
  • You would have to sign the user out off Facebook to accomplish that. See https://groups.google.com/d/msg/firebase-talk/nOQW82_c9sQ/cLfb3-3FAAAJ – Frank van Puffelen Jun 11 '16 at 23:25
  • See the answer i provided for you in the ionic forums https://forum.ionicframework.com/t/facebook-logout-with-firebase-ionic-clear-oauth-session-so-new-user-can-login/54557 – Aaron Saunders Jun 12 '16 at 13:28
  • Frank, so is that to say that all Cordova framework apps do not allow for users to log out, and have a new user input? That seems like such a sub-par solution... Are you aware of how I could accomplish this even though it'd be a crappy work flow? – njho Jun 12 '16 at 18:49

2 Answers2

0

On behalf of Aaron Saunder's comment above, by clearing the application cache, we are able to prompt for new user information (on Android Marshmellow API > 23 at least). I haven't confirmed on iPhone.

During development on the web browser, it does not exhibit this behavior however, so I guess further testing will be required to see when this is acceptable.

Uses ngCordova $cordovaInAppBrowser:

$scope.logout = function () {
    var options = {
      location: 'yes',
      clearcache: 'yes',
      toolbar: 'no',
      hidden: 'yes'
    };

    $rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
      $cordovaInAppBrowser.close();
    });
    $cordovaInAppBrowser.open('http://www.google.com', '_blank', options);

    Auth.$unauth();
    $state.go('user.signin');
};
njho
  • 2,023
  • 4
  • 22
  • 37
0

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

Aaron Saunders
  • 33,180
  • 5
  • 60
  • 80