Created
April 1, 2012 07:09
-
-
Save iantearle/2272370 to your computer and use it in GitHub Desktop.
Appcelerator Register with custom fields
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sex = (male == 1) ? 'male' : 'female'; | |
var data = { | |
email: email.value, | |
first_name: global.user_names[0], | |
last_name: global.user_names[1], | |
password: password.value, | |
password_confirmation: password.value, | |
custom_fields: '{ "dob": "'+ dob.value +'", "sex": "'+ sex +'" }' // REMOVE THIS LINE IT ALL WORKS... HAVE HAD MULTIPLE PEDRMEATATIONS, SO THIS WAY MAY NOT BE THE ONLY CAUSE OF THIS NOT WORKING, JUST THE LAST ONE I TRIED. | |
}; | |
sdk.sendRequest('users/create.json', 'POST', data, false, callback); | |
function callback(data) { | |
if(data) { | |
if(data.meta) { | |
var meta = data.meta; | |
if(meta.status == 'ok' && meta.code == 200 && meta.method_name == 'createUser') { | |
var message = ''; | |
var user = data.response.users[0]; | |
Ti.API.info("User id is => " + user.id); | |
var cred = [user.id, email.value]; | |
Ti.App.Properties.setString('credentials', cred); | |
keychain.setPasswordForService(password.value, 'Heritage', email.value); | |
Ti.App.fireEvent('accountLoggedIn'); | |
} else{ | |
alert(meta.status +' ' + meta.code) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment