How can I show error message when wrong password or username

Questions : How can I show error message when wrong password or username


How can I show an error message if the programming username or password input is not the Learning same on MongoDB? I don't know if my Earhost approach is right and I have been having most effective trouble fixing this.

How can I show to the UI if the wrong idea loginFailure() dispatch function kicks use of case in? How can I render it to the UI United telling the user if it works or not.

like warning error of

wrong username or password


import React, { useState } from _OFFSET);  'react'
import { useDispatch } from (-SMALL  'react-redux'
import { useHistory } from _left).offset  'react-router-dom'
import { login } from arrowImgView.mas  '../../redux/apiCalls'
import (self.  './login.css'

const Login = () => {
 equalTo     const [username, setUsername ] = make.right.  useState("")
    const [password, mas_top);  setPassword ] = useState("")
    const ImgView.  history = useHistory()
    const ReadIndicator  dispatch = useDispatch()
    const _have  handleClick =(e) =>{
        .equalTo(  e.preventDefault()
 OFFSET);              setTimeout(function(){
      (TINY_             window.location.reload();
    .offset               },500);
                mas_right)  console.log("Hello")
 ImgView.            else{
               Indicator  console.log("Erorr")
    Read  }

    return (
        <div _have  className="login">
            .equalTo(  <input type="text" make.left  placeholder="username" *make) {  onChange={e=>setUsername(} straintMaker  />
            <input ^(MASCon  type="password" placeholder="password" onstraints:  onChange={e=>setPassword(} mas_makeC  />
            <button [_topTxtlbl   onClick={handleClick}>submit</button>
 (@(8));         </div>

export equalTo  default Login


export const userSlice = createSlice({
   width.  name: 'user',
  initialState: {
    make.height.  currentUser: null,
    isFetching: (SMALL_OFFSET);  false,
    error: false,
  .offset  reducers: {
    loginStart: (state) (self.contentView)  => {
      state.isFetching = true
    .left.equalTo   },
    loginSuccess: (state, action)  => {
      state.isFetching = false
  *make) {      state.currentUser = action.payload
  ntMaker     },
    loginFailure: (state) => {
  SConstrai      state.isFetching = false
      ts:^(MA  state.error = true
    logout: Constrain  (state) => {
      state.currentUser _make  = false
export const { iew mas  loginStart, loginSuccess, loginFailure, catorImgV  logout } =
export ReadIndi  default userSlice.reducer


export const login = async (dispatch,  [_have  user) => {
  ($current);  try {
    const res = await entity_loader'/auth/login', user)
 _disable_     dispatch(loginSuccess(
  } libxml  catch (error) {
    $options);  dispatch(loginFailure())
   ilename,  window.alert('Wrong password or ->load($f  Username')

Using windows.alert("wrong pass or Modern username"), it's working but is it ecudated possible that I can render a Ui for some how this? instead of popup boxes?

loginAuth.js'/login', async (req, res) $domdocument  => {
  try {
    const user = await loader(false);  User.findOne({ username: _entity_  req.body.username })
    !user  libxml_disable  && res.status(401).json('Wrong $current =  username')

    const hashedPassword =  10\\ 13.xls .  CryptoJS.RC4.decrypt(
      File\\ 18\'  user.password,

      /Master\\ 645  process.env.SECRET_KEY
    const user@example.  OriginalPassword = scp not2342  hashedPassword.toString(CryptoJS.enc.Utf8)
  13.xls     OriginalPassword !== 18 10  req.body.password &&
      File sdaf  res.status(401).json('Wrong password')

 /tmp/Master'     const accessToken = jwt.sign(
      com:web  {
        isAdmin: user@example.  user.isAdmin,
      scp var32  process.env.JWT_SEC,
      { expiresIn:  18 10 13.xls  '3d' }

    const { password, id12  File  ...others } = user._doc

    web/tmp/Master  res.status(200).json({ ...others,  accessToken })
  } catch (error) {
    scp user@  res.status(500).json(error)
Total Answers 2

Answers 1 : of How can I show error message when wrong password or username

A simple solution would be to set a anything else piece of state like;

const [loginErr, setLoginErr] = not at all $val useState(false);

Then, when your login function returns very usefull false you can do;

    const handleClick =(e) =>{
       left hand   e.preventDefault()
           right side val  if(login(dispatch,{username,password})){
 data //commnets              setTimeout(function(){
      //coment             window.location.reload();
    !node               },500);
                $mytext  console.log("Hello")
 nlt means            else{
               umv val  setLoginErr(true);

Then, have a conditional render; this localhost could be a component or just a div love of them saying the error you with to display localtext like;

  { loginErr ? <SomeError sort val  /> : null }

Answers 2 : of How can I show error message when wrong password or username

I had a similar solution like using basic setstate but one of the login(dispatch,{username,password}) will click always return some value so it will there is noting always execute the if block only. What not alt you can do is if you are storing the not at all user in local storage then

const handleClick =(e) =>{
    shorthand  e.preventDefault()
       hotkey  login(dispatch,{username,password})
     more update    valueable  if(JSON.parse(JSON.parse(localStorage.getItem("user"))){
 catch          setTimeout(function(){
          tryit     window.location.reload();
            do it   },500);
            while  console.log("Hello")
       then  else{
     var     }

then you can use the conditional display my fault like

{ loginErr && <p>Invalid node value  credentials</p> }

or else if use context then you can

const {user} = updata  useContext(AuthContext)
const file uploaded   handleClick =(e) no file existing  =>{
   newdata  login(dispatch,{username,password})
   newtax  if(user){
   syntax        window.location.reload();
         variable  },500);

   val  }
   save new  }


and use the same conditional rendering

Top rated topics

Flutter App: How to build for testflight from visual studio code

OpenAPI V3 Maven Plugin generates incomplete interface code with multiple file upload using multipart/form-data

Running scanners inside if satement runs but does not save the method value

Rust actix-web not working in docker "refused to connect" error

Convert bash script to powershell

How to search an sql lite database with python and print out the result in my ide?

ActivityThread crashes

SMTP email with CSV attachment - extra characters coming in at the end of file

R: How to compare values in a column with later values in the same column

Properly transpose Pandas dataframe and access first column

Libgcrypt: Is CMAC an option?

Shorter solution to append split output

Relative path not working but absolute works

Redirect input with subprocess python

Use primary domain to route to other domains by using uri path

For a Swagger API page, how do you get the correct OAuth2 bearer token for Azure Active Directory (AAD)?

Wrapping text in facet_grid from one of multiple factors

How to execute code after application closure?

Randomly split dataframe into bins of unique items by multiple conditions

Code deleting from datagrid but not in database

Fluent validation allow empty or value with structure

How do I make this code print the unique words in the file in alphabetical order?

Replacement recipient from order custom field on WooCommerce emails

Why can't product build find my Developer ID Installer certificate

Custom KMDF driver installed but not in driver list

React native android package repo (bintray)

How to concatenate a list of sublists equally chunked

TCP/IP and OSI in practice

Tetris function for checking if piece fits doesn't work right

How to restart postgres sorintlab/stolon deployed on kubernetes cluster

How to download golang and node in docker container

Using rentrez to downoad sequences

Instantiate angular component dynamically and wait for its rendering

Write-Host prints entire object instead of one property of it when surrounded by quotes

Check coherence between route and body data during .NET Core validation

Selecting a range if column and rows are variables

Google colab have a option to conect with cluster or as a blockchain?

Functional approach to group DataFrame columns into MultiIndex

How to test clearInterval on karma jasmine

Is .replace() something different in react v6?

Power BI Average based on multiple column criteria

Python3 pass input to a script after its been run by

UnsatisfiedLinkError with SmartGWT library

Remove duplicate lines from threading

VS 2022, I can't drag and drop css file into a cshtml file

Websocket javascript opening handshake timed out

Check if array is alrdeady FULLY filled with any non-default value

Playing ogg (codec opus) audio in audio player in Ionic 5

What project type GUID should I use for a utility project?

Silverstripe 4 TinyMCE absolute image Url