Within my object "info_login," I gather account information:
async created() {
try {
const res = await axios.get(inscriptionURL);
this.comptes = res.data;
this.comptes.forEach(element => {
const data = {'pseudo': element.pseudo, 'password': element.password};
this.info_login.push(data)
});
} catch (e) {
console.error(e);
}
},
The information in "info_login" is as follows:
info_login: [
{pseudo: Nifoo, password: koko},
{pseudo: CassyDie, password: azeaze},
]
In my HTML structure:
<div class="champs">
<label for="pseudo">Pseudo</label>
<input v-model="pseudo" placeholder="Pseudo" />
</div>
<div class="champs">
<label for="password">Mot de passe</label>
<input type="password" v-model="password" placeholder="Mot de passe" />
</div>
I aim to log a message in the console only if the entered username and password match.
Currently, my methods look like this:
checkPseudo(info) {
return info.pseudo === this.pseudo;
},
checkPassword(info) {
return info.password === this.password;
},
login() {
console.log(this.info_login.find(element => element.pseudo === this.pseudo))
if (this.info_login.find(this.checkPseudo) && this.info_login.find(this.checkPassword)) {
console.log('OK OK OK OK OK');
} else {
console.log('NOOOOOOOON');
}
}
A issue arises when entering 'Nifoo' as the username and 'azeaze' as the password, resulting in the console showing 'OK OK OK OK OK.'
I seek a solution to ensure that the username corresponds to the correct password. Thank you for your assistance.