vendredi 23 octobre 2020

JavaScript IF (loginSuccess) DO (...)

The title may be misleading, however, I don't know how to phrase it exactly.

What I'm trying to achieve is a response of the correct login details from the provided list and to stop when one set of credentials is correct (see the commented out portion of code).

My issue is that I have no idea what the variable is that determines a successful login, so my question is: how do I find that variable?

In this example from CyberStart Game, when the correct credentials are inputted it will relay a flag (a string of characters) in the green area at the top. Running this code, the green box appears but no flag is presented. My theory is that the code is continuing to run after the correct credentials are inputted and it messes up the display of the flag. NOTE: There is only one set of successful login credentials.

var usrnmPswd = [
["CarlottaCarrigan", "HULUGOLFPARK"], 
["Horace-Heideman", "yelpvisa99"],
["Delfina_Detwiler", "12345"],
["AhmedAlper", "PASS_word77"],
["Annabell+Allred", "hatsaregreat"],
["aspen_van_whistlethorn", "cyclepower1999"],
["LaquandaLoy99", "LLLLPASS"],
["Liza_Van_Lundahl123", "password"],
["KentKastner", "somethinghere"],
["EarnestineEllman", "EarnyPass"],
["KimbraKyles", "KimPassword"],
["Lois-Lokey", "12345"],
["Louis@Larimore", "passwords_4eva"],
["Cornell=Clausing", "gogoSECURITY!"],
["DuaneDendy99", "99passwords"],
];

for (var i=0; i <= usrnmPswd.length; i++) {
    attemptLogin(usrnmPswd[i+1][0],usrnmPswd[i+1][1]);
    //if (loginSuccessful) {
    //    return (usrnmPswd[i+1][0],usrnmPswd[i+1][1]);
    //    break;
    //};
};

Any ideas of how I can check if a "login success" has occurred?

CyberStart Game example.

Aucun commentaire:

Enregistrer un commentaire