// Code scaffolded by goctl. Safe to edit.
package member

import (
	"context"

	"gateway/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DisableTOTPLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDisableTOTPLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DisableTOTPLogic {
	return &DisableTOTPLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
}

func (l *DisableTOTPLogic) DisableTOTP() error {
	actor, err := actorOrErr(l.ctx)
	if err != nil {
		return err
	}
	if err := requireTOTP(l.svcCtx); err != nil {
		return err
	}
	return l.svcCtx.MemberTOTP.Disable(l.ctx, actor.TenantID, actor.UID)
}
