package auth

import (
	"context"

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

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

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

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

func (l *LogoutAllLogic) LogoutAll() (resp *types.AuthLogoutAllData, err error) {
	uid, _ := middleware.UIDFrom(l.ctx)
	if err := l.svcCtx.Auth.LogoutAll(l.ctx, uid); err != nil {
		return nil, err
	}
	return &types.AuthLogoutAllData{Ok: true}, nil
}
