Page 2 of 2

Making a password screen?

Posted: Mon Mar 26, 2012 4:22 am
by meyrett

var username = Tiggr('mobiletextinput1').val();
var password = Tiggr('mobiletextinput2').val();

if (username != 'user' && password != 'pass'){
alert ('Incorrect username and password.');
return;
}

Doing exactly this gives an interesting result:
With this configuration, as long as the username is right, it doesnt matter what the password is...... you will be put through to home page. With this configuration, you have to get both username and password both wrong to be blocked and receive the "incorrect username and password".

Of course, I want to make sure they put in the right username and right password or they should receive the "incorrect username and password" message.

thanks so much.
this is 99% there. I'm thrilled and appreciative.

Best


Making a password screen?

Posted: Mon Mar 26, 2012 4:50 am
by maxkatz

It works for me. If I enter anything but 'user' and 'pass', I get the alert. Otherwise, I navigate to the 2nd page.


Making a password screen?

Posted: Mon Mar 26, 2012 4:58 am
by meyrett

Odd.
I just tested it on the emulator and on my smartphone. It lets me through as long as I get one right (un or password).
are we sure there should be a double && in there?


Making a password screen?

Posted: Mon Mar 26, 2012 5:03 am
by maxkatz

Sorry, it has to be:

code
if (username != 'user' || password != 'pass')
/code

It's OR, not AND.


Making a password screen?

Posted: Mon Mar 26, 2012 3:43 pm
by meyrett

IT WORKS!
Thanks so much.


Making a password screen?

Posted: Wed Jun 20, 2012 3:10 am
by nazario

Ok, So I have a login page that sends information back to a PHP script that checks to make sure that the password combo is correct. How do I enforce / prevent people from getting to screens without first logging in?


Making a password screen?

Posted: Wed Jun 20, 2012 3:45 am
by maxkatz

That has to be part of your app logic. You need to get some id from the server when user logs in and save it for subsequent requests. As long as the id is valid, the user is logged in.


Making a password screen?

Posted: Wed Jun 20, 2012 4:06 am
by nazario

I understand that. Currently, when a valid username password combination is submitted, a JSON representation of the logged in user is returned along with first, last name, and UID. My question is what is the best mechanism to keep a session between screens and therefor prevent from landing on a screen without proper credentials.
Along the same lines as your suggestion about a valid ID, I've thought about holding the JSON object (along with the ID) in some local tiggzi variable to then perform logic on it. If this is the best way, I have no clue how to do it :D
As of now, all the logic has been done on the back end in PHP wich means not as snappy interface for the user. If you have a suggestion as to how I should do this, I would appreciate it!


Making a password screen?

Posted: Wed Jun 20, 2012 5:09 am
by maxkatz

Yes, one way is to save the ID in browser's local storage.

http://help.tiggzi.com/documentation/...


Making a password screen?

Posted: Wed Jun 20, 2012 6:05 am
by nazario

Oh thank you. I was looking for something like this but couldn't find it. It's a great start. I am sure I'll get stuck some place.
Thanks again!