package forget

import (
	"context"
	"time"

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

// 验证手机号和验证码
func Verify(ctx context.Context, in *pb.ForgetVerifyRequest) (reply *pb.StatusReply, err error) {
	if in.Phone == "" || in.Code == "" {
		return nil, errcode.ErrInvalidArgument
	}

	pa, err := models.GetPassportAccountByField("phone", in.Phone)
	if err != nil {
		return nil, err
	}

	if pa.Status == vars.Status_Disable {
		return nil, errcode.ErrPermissionDenied
	}

	return &pb.StatusReply{
		Timeseq: time.Now().UnixMilli(),
	}, nil

}
