# Javascript - Authentication 2

<figure><img src="/files/8kW6YGDYSNsp0ymaXpGa" alt=""><figcaption></figcaption></figure>

When we click on the login button, a dialog box pops up prompting us to enter the username and password.

Let's check the source code.

<figure><img src="/files/0nepyAtdEPMbazTgzu3z" alt=""><figcaption></figcaption></figure>

* We can see that the `login.js` file is where the script is being imported from. We can follow the link to check it out.

<figure><img src="/files/CIzr9s6NaXs4LgIyL2f7" alt=""><figcaption></figcaption></figure>

So this is where the input authentication takes place.

```javascript
function connexion(){
    var username = prompt("Username :", "");
    var password = prompt("Password :", "");
    var TheLists = ["GOD:HIDDEN"];
    for (i = 0; i < TheLists.length; i++)
    {
        if (TheLists[i].indexOf(username) == 0)
        {
            var TheSplit = TheLists[i].split(":");
            var TheUsername = TheSplit[0];
            var ThePassword = TheSplit[1];
            if (username == TheUsername && password == ThePassword)
            {
                alert("Vous pouvez utiliser ce mot de passe pour valider ce challenge (en majuscules) / You can use this password to validate this challenge (uppercase)");
            }
        }
        else
        {
            alert("Nope, you're a naughty hacker.")
        }
    }
}
```

There is an array `TheLists` containing one element: `GOD:HIDDEN`.

It checks if the username entered by the user matches the username from the current element in the `TheLists` array (using `TheLists[i].indexOf(username) == 0`).

If there is a match, it splits the current element into username and password using `split(":")`, and then it compares the entered username and password with the stored values. If both match, it displays an alert with a success message.

Let's enter the credentials.

<figure><img src="/files/VqJTHEakqAZeehrLSEtL" alt=""><figcaption></figcaption></figure>

## Password

```
HIDDEN
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kunalwalavalkar.gitbook.io/write-ups/root-me/web-client/javascript-authentication-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
