Issues creating users with the "CreateUser"

Issues creating users with the "CreateUser"

I am trying to create users from another app using the CreateUser action. I am seeing several things I don't understand. I can use the debugger to follow through and see the CreateUser action receiving a User record variable, then outputing a new Id. I then have a query that searches for that new record, successfully finds it, then feeds the username and password into the "User_Login" action. When I step into the User_Login action, I see the username and password being passed in successfully from the query that is pulling it from the User table. However, it gets rejected as an "invalid login". Then when I go into my SQL management studio, and run a query on ossys_user, the new user does not show there. Furthermore, if I pull out an Advanced Query, and just type "SELECT * FROM {USER}" and test the query, I get an error "Could not assign '' to 'User.Creation_Date'... String was not recognized as a valid DateTime." Any ideas on what is going on? I don't understand this error, when I go into ossys_user and find 3 users there with no data issues (though I still don't know why the new user wasn't created).
Hi Guy, 
if you're having an invalid login exception that can be from many causes.
From the help, I can see:
Password: user password. Receives a non-encrypted input and, internally, the action encrypts it before comparison. To store this password in the database, you must use the Encrypt built-in function.

Did you save the password using the built-in? 
Are you passing the password in clear text?

As for the user not appearing in db after the error. When an error occur, the current transaction is rolledback, meaning that no userdata will appear in the database. All requests have their transaction. If the request ends sucessfully it is implicitly commited.

As for the Testquery error... thats really odd, can you please tell me what version of the server you observe that, so I can try to reproduce at my side?


I found out I was not encrypting the password, so now I am, and it still gives invalid login. I had a user that got created in my actions. Originally, it was created with a straight text password. I went into the user espace and changed the password (which is now encrypted). When I debug, I can see the "GetUser" action is successfully pulling the user I want to log in as (including username and encrypted password). I am then passing both of those parameters from the GetUser action into the User_Login action. Debug shows the right values as I Step Into User_Login action, but I still get "Invalid Login". If I try the same user credentials to login to Users espace, it works. As far as the test query goes, here is a screenshot. I am on Service Studio

Hi Guy , to reiterate, you create the user with password encrypted in the database, and you login with the cleartext. 

Thank you, Luis. I got it to work. I was using the Users action "User_Login" to try to log the user in. I passed it "Username" and "Password" from the output of the "GetUser" action. That wasn't working. I replaced the "User_Login" User action with the "Login" System action, which only requires the UserId, and now it works. Thank you for your help! The link you provided in your first answer helped me find a solution.
Hi Guy

Just a quick note, instead of using select * from {user} try to use select {user}.* from {user}