From 7f35a9594d3046c22836e3e8b33bef3495f45711 Mon Sep 17 00:00:00 2001 From: zijiren233 Date: Sat, 12 Oct 2024 21:16:25 +0800 Subject: [PATCH] fix: add oauth2 callback type --- server/oauth2/auth.go | 1 + server/oauth2/bind.go | 1 + server/oauth2/model.go | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100644 server/oauth2/model.go diff --git a/server/oauth2/auth.go b/server/oauth2/auth.go index 95a4c2b..2dfb292 100644 --- a/server/oauth2/auth.go +++ b/server/oauth2/auth.go @@ -201,6 +201,7 @@ func newAuthFunc(redirect string) stateHandler { } } else if ctx.Request.Method == http.MethodPost { ctx.JSON(http.StatusOK, model.NewApiDataResp(gin.H{ + "type": CallbackTypeAuth, "role": user.Role, "token": token, "redirect": redirect, diff --git a/server/oauth2/bind.go b/server/oauth2/bind.go index 35ac593..7e14d17 100644 --- a/server/oauth2/bind.go +++ b/server/oauth2/bind.go @@ -91,6 +91,7 @@ func newBindFunc(userID, redirect string) stateHandler { } ctx.JSON(http.StatusOK, model.NewApiDataResp(gin.H{ + "type": CallbackTypeBind, "redirect": redirect, })) } diff --git a/server/oauth2/model.go b/server/oauth2/model.go new file mode 100644 index 0000000..a9b15ce --- /dev/null +++ b/server/oauth2/model.go @@ -0,0 +1,8 @@ +package auth + +type CallbackType string + +const ( + CallbackTypeAuth CallbackType = "auth" + CallbackTypeBind CallbackType = "bind" +)