Page 1 of 1

Simple login script without database

Posted: Fri Jan 13, 2017 1:16 pm
by Lars Holtet

Hi!

Does anybody have an example for a simple js loginscript without a DB with the jquery input Fields? Users can be "hardcoded", no registration.


Simple login script without database

Posted: Fri Jan 13, 2017 7:39 pm
by Serhii Kulibaba

Hello Lars,

Sure, it is possible to do with a Storage variables, which have a list of users, or use hard-cored array, which you can check with a condition like:
prefor(var i = 0; i< users&#46;length; i++){
if((Apperyio("username")&#46;val() === users&#46;name)&&(Apperyio("password")&#46;val() === users&#46;password)){
alert("signed in");
break;
}
}/pre
here username and password - names of input fields in your app

users - an array of objects with names and passwords


Simple login script without database

Posted: Sat Jan 14, 2017 12:54 am
by Lars Holtet

Thanks! I just need to hardcode 1 user to go to one certain page, am i on the right direction?

Image


Simple login script without database

Posted: Sat Jan 14, 2017 11:05 am
by Lars Holtet

Thanks! I just need to hardcode 1 user to go to one certain page, am i on the right direction?

Image


Simple login script without database

Posted: Sat Jan 14, 2017 12:35 pm
by Lars Holtet

"

"

This also serves the purpose, but how do i convert it to work with a a button made in appery?


Simple login script without database

Posted: Sat Jan 14, 2017 12:36 pm
by Lars Holtet

function passWord() {
var testV = 1;
var pass1 = prompt('Please Enter Your Password',' ');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1.toLowerCase() == "letmein") {
alert('You Got it Right!');
window.open('protectpage.html');
break;
}
testV+=1;
var pass1 =
prompt('Access Denied - Password Incorrect, Please Try Again.','Password');
}
if (pass1.toLowerCase()!="password" & testV ==3)
history.go(-1);
return " ";
}


Simple login script without database

Posted: Sat Jan 14, 2017 12:37 pm
by Lars Holtet

http://www.javascriptkit.com/script/c...

This would cover what im after, i just need to make it work with "on click" - javascript one of my buttons made in the app?


Simple login script without database

Posted: Sat Jan 14, 2017 1:55 pm
by Lars Holtet

Ok, i got a form that worked:

'

'


Simple login script without database

Posted: Sat Jan 14, 2017 1:57 pm
by Lars Holtet

This works with 2 input fields in the appery editor. The only thing i cant get to work is the buttons.. In the HTML form here, it makes its own button- but i want to make my own. How would that JS code be different from this html one "on click"?


Simple login script without database

Posted: Tue Jan 17, 2017 1:06 pm
by Serhii Kulibaba

Please add a new property "page" into the array users and compare it with the current page:

prevar currentPage = $("&#46;ui-page-active")&#46;attr("id");
if (users&#46;page === currentPage){
alert("Curren page is available!");
}/pre