Get 2024 Templates Mega Bundle!14 Bootstrap, Vue & React Templates + 3 Vector Sets
Get for 99$

Metronic Laravel 8.2.3 login response handle js deadcode


Hi team,

I'm working on Metronic Laravel 8.2.3 for my frontend.
Btw, when I login FE never display "Sorry, the email or password is incorrect, please try again."
It only displays:
- "You have successfully logged in!"
- "Sorry, looks like there are some errors detected, please try again."

I do search and found out in "public/assets/js/custom/authentication/sign-in/general.js"
you handle case "Sorry, the email or password is incorrect, please try again." in branch else of if (response)

if (response)
"You have successfully logged in!"
else
"Sorry, the email or password is incorrect, please try again."

I think we could never go to else branch.
Please advise.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)


Hi,

Sorry for the delay. It seems there might be an issue with the handling of error responses in the login process. You can update the code in the catch block as follows:


.catch(function (error) {
if (error.response.status !== 200) {
Swal.fire({
text: "Sorry, the email or password is incorrect, please try again.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
} else {
Swal.fire({
text: "An error occurred. Please try again later.",
icon: "error",
buttonsStyling: false,
confirmButtonText: "Ok, got it!",
customClass: {
confirmButton: "btn btn-primary"
}
});
}
});


This code checks if the error response status is 422, which is the status typically used for validation errors, such as an incorrect email or password during login. If the status is not 200, it displays the appropriate error message. Otherwise, it displays a generic error message. This should ensure that users are notified when their login credentials are incorrect. We'll also make sure to address this in the next release to provide a more seamless experience. Thank you for your patience and understanding. If you have any further questions or concerns, please don't hesitate to ask.


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(