Edits or limits on 'built in' client api requests?
J
Jeff Amiel
started a topic
over 6 years ago
Obviously with my own events, I can put whatever checks/restrictions on inbound data as I want in the cloud code - but with events like ChangeUserDetailsRequest (GameSparks provided) - are there any edits/limits on the values sent in - specifically displayName?
I see that I can add my own code to the ChangeUserDetailsRequest request - is that code executed AFTER the functionality that GameSparks provides or BEFORE? If it was before, I could possibly add some edit restrictions (length, bad language check, etc) and then either generate error condition or 'scrub' the value before it was persisted.
Thoughts?
(Obviously - I could create my own field in in Player or my own collection and my own events to populate - but displayName seemed 'correct' and already provided...)
Thanks in advance!!
Best Answer
C
Customer Support
said
over 6 years ago
Hi Jeff,
You can use 'throw' to stop a request in it's tracks and send the appropriate error. A simple example using some Cloud Code in the RegistrationRequest would be as follows.
//get the password the user just supplied
var userPassword = Spark.getData().password;
//if the password is blank, throw an "Invalid Password" error
if(userPassword == ""){
throw "Password Invalid";
}
With this you could add your own checks in the RegistrationRequest and throw appropriate errors to the user where needed. Hope this helps.
You can use 'throw' to stop a request in it's tracks and send the appropriate error. A simple example using some Cloud Code in the RegistrationRequest would be as follows.
//get the password the user just supplied
var userPassword = Spark.getData().password;
//if the password is blank, throw an "Invalid Password" error
if(userPassword == ""){
throw "Password Invalid";
}
With this you could add your own checks in the RegistrationRequest and throw appropriate errors to the user where needed. Hope this helps.
Jeff Amiel
Obviously with my own events, I can put whatever checks/restrictions on inbound data as I want in the cloud code - but with events like ChangeUserDetailsRequest (GameSparks provided) - are there any edits/limits on the values sent in - specifically displayName?
I see that I can add my own code to the ChangeUserDetailsRequest request - is that code executed AFTER the functionality that GameSparks provides or BEFORE? If it was before, I could possibly add some edit restrictions (length, bad language check, etc) and then either generate error condition or 'scrub' the value before it was persisted.
Thoughts?
(Obviously - I could create my own field in in Player or my own collection and my own events to populate - but displayName seemed 'correct' and already provided...)
Thanks in advance!!
Hi Jeff,
You can use 'throw' to stop a request in it's tracks and send the appropriate error. A simple example using some Cloud Code in the RegistrationRequest would be as follows.
With this you could add your own checks in the RegistrationRequest and throw appropriate errors to the user where needed. Hope this helps.
Thanks,
Liam
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Jeff,
You can use 'throw' to stop a request in it's tracks and send the appropriate error. A simple example using some Cloud Code in the RegistrationRequest would be as follows.
With this you could add your own checks in the RegistrationRequest and throw appropriate errors to the user where needed. Hope this helps.
Thanks,
Liam
Jeff Amiel
Exactly what I was looking for....thanks!!
(mark as 'Answered' please)
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics