Cloudboost logout function

99 views Asked by At

When I try to log out the current user of my app I get this message : TypeError: CB.CloudUser.current.logOut is not a function

Here is my code :

$scope.logout = function() {
        CB.CloudUser.current.logOut({
            success: function(user) {
                //log out successfull
                var currentUser = user;
                $timeout(function() {
                    $scope.userConnected = false;
                    document.getElementById("body-container").className = "hold-transition login-page";
                });
            },
            error: function(err) {
                //Error occured in user registration.
            }
        });

Thank you for your help.

2

There are 2 answers

0
malignois On

Here is what I have in CB.CloudUser.current:

CB.CloudObject {document: Object}
ACL: (...)
createdAt: (...)
document: Object
ACL: CB.ACL
_id: "OUVrZf9T"
_tableName: "User"
_type: "custom"
_version: 1
createdAt: "2016-02-27T21:15:09.013Z"
email: ""
expires: null
password: ""
updatedAt: "2016-02-27T21:15:27.403Z"
username: "malignois"
__proto__: Object
expires: (...)
id: (...)
updatedAt: (...)
__proto__: CB.CloudObject
0
jdubicki On

I know this is old but this is what works for me. I am using Ionic 2, but the syntax should be the same. Hope this helps.

  CB.CloudUser.getCurrentUser({
    success: function (user) {
      // Success getting current user
      user.logOut({
        success: function () {
          // Success logging out
        },
        error: function () {
          // Error logging out
        }
      });
    },
    error: function () {
      // Error getting current user
    }
  });