Both cases password error returning why?

here both the cases when an user entered a wrong password or even right password error returning why?
also how can i show user that their email is also wrong?

func Login(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Content-Type", "application/json")
	var user model.User
	var dbUser model.User
	if err := json.NewDecoder(r.Body).Decode(&user); err == nil {
		if _, err := service.Login_User(&user); err == nil {
			json.NewEncoder(w).Encode(user)
		} else {
			w.WriteHeader(http.StatusInternalServerError)
			//w.Write([]byte)
			json.NewEncoder(w).Encode(err)
		}
	} else {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	userPass := []byte(user.Password)
	dbPass := []byte(dbUser.Password)
	PassErr := bcrypt.CompareHashAndPassword(dbPass, userPass)
	if PassErr != nil {
		w.Write([]byte(`{"response":"Wrong Password"}`))
		return
	}
}

Hi @Rajrup_Das,

The function does not seem to fill dbUser anywhere.

Regarding email, I guess there is a field in model.User, and you would need to validate the email string by checking if it contains a"@" and does not contain characters that are illegal in an email address. There should be packages available for that. (Search pkg.go.dev, I am sure you’ll find more than a few.)

I have also same error any suggestion for this so please reply. Thanks in advance.