Page 1 of 1

Test if user exists

Posted: Tue Jan 29, 2013 1:04 pm
by Joe Bohen

Hi,

I want to test if a user exists in the Tiggzi database using username and not _id can I do this as you would do from other collections?

Regards,
Joe


Test if user exists

Posted: Tue Jan 29, 2013 3:55 pm
by Joe Bohen

Hi,

Do you understand my question? I want to test if a user already has an account by querying the users table using the username as a parameter and if no record exists then add a record.

I am able to add a record and if I attempt to duplicate an existing user I get an 400 Bad Request error returned. But if I try to query the uses table I get a 401 authentication error. How do I get the users returned? Or do I simply use the error as an indication that the record already exists.

Regards,
joe


Test if user exists

Posted: Tue Jan 29, 2013 4:47 pm
by Kateryna Grynko

Hi Joe,

To check if user exists in database you can test HTTP Status for login service.

Error = 400 - User exists but password is incorrect
Error = 404 - User doesn't exist

You can get error code via JavaScript added to "Error" action for login service:
codeif (jqXHR.status == 404) {
alert("No such user!");
}
else if(jqXHR.status == 400) {
alert("Invalild password");
}/code


Test if user exists

Posted: Tue Jan 29, 2013 5:07 pm
by Joe Bohen

Thanks Katya I will give it a go.