func (u *User) GetWithPassword(password string) error {
	var user User
	db.Get(&user, "SELECT id, name, password FROM users WHERE name = ?", u.Name)

	if user.Name == u.Name {
		err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
		switch {
		case err == nil:
			*u = user
			return nil
		case err == bcrypt.ErrMismatchedHashAndPassword:
			return ErrNoMatchNamePassword
		default:
			return err
		}
	} else {
		return ErrNoSuchUser
	}
}
// GetWithPassword finds out whether the given password matches the password of user.
// If these don't match an error is returned. This can be ErrNoMatchNamePassword, ErrNoSuchUser
// or an error indicating that something in the password hashing went wrong.
//	err := user.GetWithPassword(password)
//	switch {
//	case err == nil:
//		// The user can get logged in or somthing.
//	case err == model.ErrNoMatchNamePassword:
//		// Maybe return a message to the user.
//	case err == model.ErrNoSuchUser:
//		// Maybe tell the user the username was wrong.
//	default:
//		// Some kind of internal error.
//	}
GetWithPassword finds out whether the given password matches the password of user.
If these don't match an error is returned. This can be ErrNoMatchNamePassword, ErrNoSuchUser
or an error indicating that something in the password hashing went wrong.
err := user.GetWithPassword(password)
switch {
case err == nil:
The user can get logged in or somthing.
case err == model.ErrNoMatchNamePassword:
Maybe return a message to the user.
case err == model.ErrNoSuchUser:
Maybe tell the user the username was wrong.
default:
Some kind of internal error.
// GetWithPassword finds out whether the given password matches the password of user . // If these don ' t match an error is returned . This can be ErrNoMatchNamePassword ErrNoSuchUser // or an error indicating that something in the password hashing went wrong . // err : = user . GetWithPassword ( password ) // switch { // case err == nil : // // The user can get logged in or somthing . // case err == model . ErrNoMatchNamePassword : // // Maybe return a message to the user . // case err == model . ErrNoSuchUser : // // Maybe tell the user the username was wrong . // default : // // Some kind of internal error . // }
func (u *User) GetWithPassword(password string) error {
	var user User
	db.Get(&user, "SELECT id, name, password FROM users WHERE name = ?", u.Name)
	if user.Name == u.Name {
		err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
		switch {
		case err == nil:
			*u = user
			return nil
		case err == bcrypt.ErrMismatchedHashAndPassword:
			return ErrNoMatchNamePassword
		default:
			return err
		}
	} else {
		return ErrNoSuchUser
	}
}
func ( u * User ) GetWithPassword ( password string ) error { var user User db . Get ( & user , " " , u . Name ) if user . Name == u . Name { err := bcrypt . CompareHashAndPassword ( [ ] byte ( user . Password ) , [ ] byte ( password ) ) switch { case err == nil : * u = user return nil case err == bcrypt . ErrMismatchedHashAndPassword : return ErrNoMatchNamePassword default : return err } } else { return ErrNoSuchUser } }
GetWithPassword finds out whether the given password matches the password of user.
GetWithPassword finds out whether the given password matches the password of user .