Lars Holtet
Posts: 0
Joined: Sun Nov 24, 2013 5:47 pm

Simple login script without database

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.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Simple login script without database

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

Lars Holtet
Posts: 0
Joined: Sun Nov 24, 2013 5:47 pm

Simple login script without database

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

Image

Lars Holtet
Posts: 0
Joined: Sun Nov 24, 2013 5:47 pm

Simple login script without database

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

Image

Lars Holtet
Posts: 0
Joined: Sun Nov 24, 2013 5:47 pm

Simple login script without database

"

"

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

Lars Holtet
Posts: 0
Joined: Sun Nov 24, 2013 5:47 pm

Simple login script without database

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 " ";
}

Lars Holtet
Posts: 0
Joined: Sun Nov 24, 2013 5:47 pm

Simple login script without database

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?

Lars Holtet
Posts: 0
Joined: Sun Nov 24, 2013 5:47 pm

Simple login script without database

Ok, i got a form that worked:

'

'

Lars Holtet
Posts: 0
Joined: Sun Nov 24, 2013 5:47 pm

Simple login script without database

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"?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Simple login script without database

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

Return to “Issues”