package register

import (
	"context"

	"bsm/full/module/base/passport/internal/models"
	pb "bsm/full/module/base/passport/pb"
	"git.apinb.com/bsm-sdk/core/errcode"
)

// 帐号密码注册
func Pwd(ctx context.Context, in *pb.RegisterRequest) (reply *pb.RegisterReply, err error) {
	if in.Account == "" || in.Password == "" {
		return nil, errcode.ErrInvalidArgument
	}

	//账号唯一验证
	found := models.PassportAccountExists("account", in.Account)
	if found {
		return nil, errcode.ErrAlreadyExists
	}

	return Do(in)
}
