Exemple #1
0
// 修改密码,旧密码可为空
func (this *Member) ModifyPassword(newPwd, oldPwd string) error {
	var err error

	if b, err := domain.ChkPwdRight(newPwd); !b {
		return err
	}

	if len(oldPwd) != 0 {
		dyp := domain.Md5MemberPwd(oldPwd)
		if dyp != this._value.Pwd {
			return errors.New("原密码不正确")
		}
	}

	this._value.Pwd = domain.Md5MemberPwd(newPwd)
	_, err = this.Save()

	return err
}
Exemple #2
0
// 修改密码,旧密码可为空
func (this *Member) ModifyPassword(newPwd, oldPwd string) error {
	var err error
	if newPwd == oldPwd {
		return member.ErrPwdCannotSame
	}

	if b, err := domain.ChkPwdRight(newPwd); !b {
		return err
	}

	if len(oldPwd) != 0 && oldPwd != this._value.Pwd {
		return member.ErrPwdOldPwdNotRight
	}

	this._value.Pwd = newPwd
	_, err = this.Save()

	return err
}