예제 #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
}
예제 #2
0
파일: member.go 프로젝트: zoe527/go2o
// 修改密码,旧密码可为空
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
}