Looks like some mis-understanding got through the review process on the guide. Anyway, here is what gets returned in event.response:
This is a failure
table: 0x10f9f38c0 { [type] =\> "registerUser" [name] =\> "authentication" [response] =\> "{"username":["has already been taken"],"email":["is already taken"],"base":["Password must be at least 6 chars long"]}" }
If you json.decode(event.response) it looks like username, email, and/or base will be a table with a single entry in it. BTW: This shows all three failures. So some code like:
if event.error == nil then local r = json.decode(event.response) if r.email then print("email " .. r.email[1]) elseif r.base then print("password " .. r.base[1]) elseif r.username and type(r.username) == "table" then print(username .. r.username[1]) else print("login after successful registration") local loginParams = {} loginParams.type = "user" loginParams.email = settings.email loginParams.password = settings.password cloud.login( loginParams ) end else print("Some network error happened") end
I tested this in one of my apps and it seems to catch the right things. A successful register returns this table of information:
table: 0x11007b9f0 { [type] =\> "registerUser" [name] =\> "authentication" [response] =\> "{"\_id":"51bcdb87ba187bc75800001f","achievements":null,"activated\_at":null,"active":false,"city":null,"country":null,"created\_at":"2013-06-15T21:24:23+00:00","facebook\_enabled":null,"facebook\_id":null,"first\_name":"iap","game\_ids":["51324a0a649329244f000002"],"last\_device\_used":null,"last\_game\_played":null,"last\_login":null,"last\_name":"iap","location\_lat":null,"long\_coords":null,"notification\_channel\_ids":[],"points":0,"profile\_picture\_content\_type":null,"profile\_picture\_file\_name":null,"profile\_picture\_file\_size":null,"profile\_picture\_updated\_at":null,"remember\_token":null,"remember\_token\_expires\_at":null,"reset\_code":null,"signed\_up\_from\_facebook":false,"twitter\_access\_secret":null,"twitter\_enabled":null,"twitter\_id":null,"updated\_at":"2013-06-15T21:24:23+00:00","username":"iap04z"}" }
Note, the password and email will never be set in a successful return. Also the username entry is a string, not a table.
Rob