package auth

import (
	"context"

	"apps/backend/internal/svc"
	"apps/backend/internal/types"

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

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

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

func (l *LogoutLogic) Logout(req *types.AuthLogoutReq) (resp *types.OkData, err error) {
	l.svcCtx.Auth.Logout(req.RefreshToken)
	return &types.OkData{Ok: true, Message: "logged out"}, nil
}
