Below is the code i use for my cloud user login...the slight problem is; whenever i login and logout, data inserted into the textfields does not disappear...i don't want them to be saved, i want users to insert textfields all over again after logout.
//create textfields for sign_in page/interface
var userNameField = Titanium.UI.createTextField({
color: 'black',
hintText: 'username',
height: 35,
top: 120,
left: 10,
width: 250,
borderStyle: Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(userNameField);
var passwordField = Titanium.UI.createTextField({
color: 'black',
hintText: 'password',
height: 35,
top: 160,
left: 10,
width: 250,
passwordMask: true,
borderStyle: Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
});
win.add(passwordField);
var button = Titanium.UI.createButton({
title: 'log in',
top: 190,
left: 10,
width: 100,
height:50,
Color:'#336699'
});
win.add(button);
//then create event listener and login user to ACS cloud server
button.addEventListener('click', function(){
Cloud.Users.login({
login: userNameField.value,
password: passwordField.value,
}, function (e) {
if (e.success) {
var user = e.users[0];
alert('success');
} else {
alert('Unable to log you in:' + e.message);
}
});
});