Greetings! I have designed a login page where the user will be logged in if the response is successful, otherwise an error message will be displayed. Below is the JSON data with email and password fields:
{
Email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="600d011817090c2005030f1705024e030f0d">[email protected]</a>",
password:56897
}
Here is the login method implementation:
this.serv.getLogin(data.Email,data.password).subscribe(res=>{
if (res.Data.Id === 0 && res.Data.Id === null || res.Status === 'false') {
alert('please check the username or password');
return false;
} else {
console.log(res);
localStorage.setItem('UserDetails', JSON.stringify(res));
this.router.navigate(['/TrackDriver']);
return true;
}
},err => {
console.log(err);
});
The issue here is that it still logs in even with incorrect credentials. However, when using the correct email and password provided above, the login is successful.
{
"Data": {
"Email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3e535f464957527e5b5d51495b5c105d5153">[email protected]</a>",
"Id": "1",
"Name": "Admin"
},
"ErrorCode": "201 - Success",
"Message": "Success",
"Status": true
}
Even with incorrect details, the system logs in and returns the following response:
{
"Data": {
"Email": null,
"Id": null,
"Name": null
},
"ErrorCode": "501 - No Data Found",
"Message": "Please Check Credentials",
"Status": false
}
Despite providing incorrect details, the system still allows login. The cause of this issue remains unclear to me.