29 lines
832 B
Go
29 lines
832 B
Go
package oauth
|
|
|
|
import (
|
|
"github.com/zeromicro/go-zero/rest/httpx"
|
|
"net/http"
|
|
"schisandra-album-cloud-microservices/app/auth/api/internal/logic/oauth"
|
|
"schisandra-album-cloud-microservices/app/auth/api/internal/svc"
|
|
"schisandra-album-cloud-microservices/app/auth/api/internal/types"
|
|
"schisandra-album-cloud-microservices/common/xhttp"
|
|
)
|
|
|
|
func GithubCallbackHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
var req types.OAuthCallbackRequest
|
|
if err := httpx.Parse(r, &req); err != nil {
|
|
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
|
return
|
|
}
|
|
|
|
l := oauth.NewGithubCallbackLogic(r.Context(), svcCtx)
|
|
data, err := l.GithubCallback(r, &req)
|
|
if err != nil {
|
|
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
|
} else {
|
|
xhttp.OkHTML(w, data)
|
|
}
|
|
}
|
|
}
|