Create user ACS

You must Login before you can answer or comment on any questions.

I can show my code if need be but I pretty much followed this link verbatim http://burrsutter.blogspot.com/2012/04/my-getting-started-experience-with.html

I can create a user once and its successful but every time i try to create a user with a different name or relaunch the simulator and create another user I get "Fail" any ideas whats going on?

— asked 11 months ago by shane p
2 Comments
  • HI Shane, it will be good if you could provide a code snippet.

    — commented 11 months ago by Ashish Nigam

  • here is my function that creates the user sign up window

    var Cloud = require('ti.cloud');
    var winsignup = Titanium.UI.createWindow({
        title:'Sign Up!',
        tabBarHidden:true,
        borderRadius:0,
        backgroundColor:'#336699'
       });
     
    var label = Ti.UI.createLabel({
        text: 'Sign Up!',
        color: '#fff',
        top:0,
        textAlign:'center',
        font: {
            fontWeight: 'bold',
            fontSize: 18
        },
        height:'auto',
    });
    winsignup.add(label);
     
    var userNameField = Titanium.UI.createTextField({
        color:'#336699',
        top:50,
        left:10,
        width:300,
        height:40,
        hintText:'userNameField',
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
    });
    winsignup.add(userNameField);
     
    var passwordField = Titanium.UI.createTextField({
        color:'#336699',
        top:100,
        left:10,
        width:300,
        height:40,
        hintText:'passwordField',
        passwordMask:true,
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
    });
    winsignup.add(passwordField);
     
    var passwordConfirmation = Titanium.UI.createTextField({
        color:'#336699',
        top:150,
        left:10,
        width:300,
        height:40,
        hintText:'passwordConfirm',
        passwordMask:true,
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
    });
    winsignup.add(passwordConfirmation);
     
    var firstName = Titanium.UI.createTextField({
        color:'#336699',
        top:200,
        left:10,
        width:300,
        height:40,
        hintText:'firstName',
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
    });
    winsignup.add(firstName);
     
    var lastName = Titanium.UI.createTextField({
        color:'#336699',
        top:250,
        left:10,
        width:300,
        height:40,
        hintText:'lastName',
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
    });
    winsignup.add(lastName);
     
    var Create = Titanium.UI.createButton({
        title:'Create',
        top:300,
        width:90,
        height:35,
        borderRadius:1,
        font:{fontWeight:'bold',fontSize:14}
    });
    winsignup.add(Create);
    winsignup.open();
     
     
      Create.addEventListener('click', function() {
            Cloud.Users.create ({
                username: userNameField.value,
                password: passwordField.value,
                password_confirmation : passwordConfirmation.value,
                firstName: firstName.value,
                lastName: lastName.value,
            }, function (e) {
                if (e.success) {
                    alert('Success');
                } else {
                    alert('Fail');
                }
            });
        });

    — commented 11 months ago by shane p

2 Answers

Maybe if you actually had your success/fail function do something useful, you might know what the reason actually is:

function (e) {
   if (e.success) {
      alert('Success');
   } else {
      Ti.API.error(JSON.stringify(e)                
      alert('Fail');
   }
});
Now check your logs and see WHY you are having a failure.

I'd lean towards you are already logged in.

Hi Shane, Stephen has mentioned the correct point. check the message in case of your failure. once you logged in and created an account, logout first then create new one.

Your Answer

Think you can help? Login to answer this question!