Skip to main content
All CollectionsGeneral questions
Restrict anonymous login to create new accounts
Restrict anonymous login to create new accounts

authentication pre-hook

Jason Liang avatar
Written by Jason Liang
Updated over a week ago

Certain applications may restrict end-users from signing on using anonymous identities, and consider to prevent unauthorized individuals from hacking into the client and creating anonymous accounts. In such scenarios, the brainCloud API hooks feature can be used by attaching a pre-hook script to Authenticate API. The script will then modify the forceCreate parameter to false for the Anonymous authentication type. Refer to the script example provided below.

"use strict";

function main() {
var response = {};
response.status = 200;

bridge.logInfoJson("Script Inputs", data);

if (data.message.authenticationType == "Anonymous" && data.message.forceCreate) {

response.messageOverride = JSON.parse(JSON.stringify(data.message));

response.messageOverride.forceCreate = false;

}
return response;
}

main();
Did this answer your question?