Skip to content

Commit

Permalink
Merge pull request #199 from getbraincloud/release/5.2
Browse files Browse the repository at this point in the history
Release/5.2
  • Loading branch information
francobithead authored Feb 14, 2024
2 parents b705c45 + 343add9 commit ffc3393
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 12 deletions.
4 changes: 2 additions & 2 deletions deploy/node/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion deploy/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "braincloud",
"version": "5.1.1",
"version": "5.2.0",
"description": " brainCloud client for NodeJS",
"main": "index.js",
"react-native": "react-native.js",
Expand Down
2 changes: 1 addition & 1 deletion src/brainCloudClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function BrainCloudClient() {
}


bcc.version = "5.1.1";
bcc.version = "5.2.0";
bcc.countryCode;
bcc.languageCode;

Expand Down
14 changes: 13 additions & 1 deletion src/brainCloudWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ function BrainCloudWrapper(wrapperName) {
*
*/
bcw.authenticateAnonymous = function(responseHandler) {

bcw._initializeIdentity(true);

bcw.brainCloudClient.authentication.authenticateAnonymous(
Expand Down Expand Up @@ -1263,6 +1262,19 @@ function BrainCloudWrapper(wrapperName) {
}
});
}

/**
* Logs user out of server.
* @param {boolean} forgetUser Determines whether the stored profile ID should be reset or not
* @param {*} responseHandler Function to invoke when request is processed
*/
bcw.logout = function(forgetUser, responseHandler){
if(forgetUser){
bcw.resetStoredProfileId()
}

bcw.brainCloudClient.playerState.logout(responseHandler)
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 32 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ function createUser(prefix, randomId)
return {
name : prefix + "-" + randomId,
password : prefix + "-" + randomId,
email : prefix + "-" + randomId + "@testuser.test",
email : prefix + "-" + randomId + "@test.getbraincloud.com",
playerId : null
};
}
Expand Down Expand Up @@ -3158,7 +3158,7 @@ async function testIdentity() {

await asyncTest("changeEmailIdentity()", 2, function() {

let newEmail = "test_" + getRandomInt(0,1000000) + "@bitheads.com";
let newEmail = "test_" + getRandomInt(0,1000000) + "@test.getbraincloud.com";

bc.identity.changeEmailIdentity(
UserC.email,
Expand Down Expand Up @@ -3189,7 +3189,7 @@ async function testMail() {

await asyncTest("updateContactEmail()", 2, function() {
bc.playerState.updateContactEmail(
"braincloudunittest@gmail.com",
"braincloudunittest@test.getbraincloud.com",
function(result) {
ok(true, JSON.stringify(result));
equal(result.status, 200, "Expecting 200");
Expand Down Expand Up @@ -3619,7 +3619,7 @@ async function testPlayerState() {
});

await asyncTest("updateContactEmail()", 2, function() {
bc.playerState.updateContactEmail("something@bctestdomain.com", function(
bc.playerState.updateContactEmail("something@test.getbraincloud.com", function(
result) {
ok(true, JSON.stringify(result));
equal(result.status, 200, "Expecting 200");
Expand Down Expand Up @@ -5248,14 +5248,14 @@ async function testSharedIdentity() {
});

await asyncTest("attachNonLoginUniversalId()", function() {
bc.identity.attachNonLoginUniversalId("braincloudtest@gmail.com", function(result) {
bc.identity.attachNonLoginUniversalId("braincloudtest@test.getbraincloud.com", function(result) {
equal(result.status, 403, JSON.stringify(result));
resolve_test();
});
});

await asyncTest("updateUniversalLoginId()", function() {
bc.identity.updateUniversalIdLogin("braincloudtest@gmail.com", function(result) {
bc.identity.updateUniversalIdLogin("braincloudtest@test.getbraincloud.com", function(result) {
equal(result.status, 403, JSON.stringify(result));
resolve_test();
});
Expand Down Expand Up @@ -5782,6 +5782,32 @@ async function testWrapper()
});
});
});

function testLogout(forgetUser, logoutCallback){
bc.resetStoredProfileId()

bc.authenticateAnonymous(function() {
bc.logout(forgetUser, logoutCallback)
});
}

await asyncTest("logout() remember user", 2, function () {
testLogout(false, function(result) {
equal(result.status, 200, JSON.stringify(result));

equal(bc.getStoredProfileId() == "", false, "Profile ID was NOT reset: " + bc.getStoredProfileId())
resolve_test()
})
})

await asyncTest("logout() forget user", 2, function () {
testLogout(true, function(result) {
equal(result.status, 200, JSON.stringify(result));

equal(bc.getStoredProfileId() == "", true, "Profile ID WAS reset: " + bc.getStoredProfileId())
resolve_test()
})
})
}

////////////////////////////////////////
Expand Down

0 comments on commit ffc3393

Please sign in to comment.