package auth

import (
	"net/http"

	"git.noahlan.cn/noahlan/ntool-biz/zero/statusz"

	"git.noahlan.cn/n-admin/n-admin-server/api/internal/logic/auth"
	"git.noahlan.cn/n-admin/n-admin-server/api/internal/svc"
)

// swagger:route get /api/auth/oauth/login/callback auth OauthCallback
//
// Oauth log in callback route | Oauth 登录返回调接口，即redirect_uri
//
// Oauth log in callback route | Oauth 登录返回调接口，即redirect_uri
//
// Responses:
//  200: LoginResp

func OauthCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		const transErr = true

		l := auth.NewOauthCallbackLogic(r, r.Context(), svcCtx)
		resp, err := l.OauthCallback()

		statusz.ResponseHandler(r, w, transErr, resp, err)

	}
}
