diff --git a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go index 09f83aee..7a70bf91 100644 --- a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go +++ b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go @@ -53,6 +53,8 @@ func Routers(r *gin.RouterGroup) { r.POST("/wxLogin", wxLogin) //微信二维码 r.GET("/wxShowImg", wxShowImg) + //检查OpenId + r.GET("/checkOpenId", checkOpenId) return } @@ -661,9 +663,9 @@ func checkOpenId(context *gin.Context) { //3、写cookie context.SetCookie(ConfigUtil.AccessToken, encodeString, 0, "/", "", false, true) //4、跳转到XXX页面,比如集成页,或者管理员的首页 - if identityId==1{ + if identityId == 1 { context.Redirect(301, "/dsBaseWeb/#/organization/bureau") - }else{ + } else { context.Redirect(301, "/dsBaseWeb/pages/personPortal/") } } else { diff --git a/dsSso/docs/docs.go b/dsSso/docs/docs.go index b54e0230..7dbcd755 100644 --- a/dsSso/docs/docs.go +++ b/dsSso/docs/docs.go @@ -200,6 +200,38 @@ var doc = `{ ] } }, + "/oauth2/checkOpenId": { + "get": { + "description": "检查OPENID的是否已经绑定", + "consumes": [ + "application/x-www-form-urlencoded" + ], + "produces": [ + "application/json" + ], + "tags": [ + "登录验证类" + ], + "summary": "检查OPENID的是否已经绑定", + "parameters": [ + { + "type": "string", + "description": "OpenId", + "name": "openid", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } + } + }, "/oauth2/getCaptcha": { "get": { "description": "获取验证码(为了以后WEB服务器的集群扩展,将验证码保存到redis中,避免ip_hash)", @@ -706,7 +738,7 @@ type swaggerInfo struct { // SwaggerInfo holds exported Swagger Info so clients can modify it var SwaggerInfo = swaggerInfo{ Version: "2.0", - Host: "127.0.0.1:8000", + Host: "10.10.14.187:8000", BasePath: "", Schemes: []string{}, Title: "东师理想统一认证中心(OAuth2+Sso)", diff --git a/dsSso/docs/swagger.json b/dsSso/docs/swagger.json index 42bb8e92..40a0a557 100644 --- a/dsSso/docs/swagger.json +++ b/dsSso/docs/swagger.json @@ -7,7 +7,7 @@ "license": {}, "version": "2.0" }, - "host": "127.0.0.1:8000", + "host": "10.10.14.187:8000", "paths": { "/oauth2/access_token": { "post": { @@ -184,6 +184,38 @@ ] } }, + "/oauth2/checkOpenId": { + "get": { + "description": "检查OPENID的是否已经绑定", + "consumes": [ + "application/x-www-form-urlencoded" + ], + "produces": [ + "application/json" + ], + "tags": [ + "登录验证类" + ], + "summary": "检查OPENID的是否已经绑定", + "parameters": [ + { + "type": "string", + "description": "OpenId", + "name": "openid", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "string" + } + } + } + } + }, "/oauth2/getCaptcha": { "get": { "description": "获取验证码(为了以后WEB服务器的集群扩展,将验证码保存到redis中,避免ip_hash)", diff --git a/dsSso/docs/swagger.yaml b/dsSso/docs/swagger.yaml index b98c54f6..f700c68e 100644 --- a/dsSso/docs/swagger.yaml +++ b/dsSso/docs/swagger.yaml @@ -32,7 +32,7 @@ definitions: description: 个数 type: object type: object -host: 127.0.0.1:8000 +host: 10.10.14.187:8000 info: contact: {} description: 参考自xxl-sso @@ -160,6 +160,27 @@ paths: - value x-intlimit: - device_id + /oauth2/checkOpenId: + get: + consumes: + - application/x-www-form-urlencoded + description: 检查OPENID的是否已经绑定 + parameters: + - description: OpenId + in: query + name: openid + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + type: string + summary: 检查OPENID的是否已经绑定 + tags: + - 登录验证类 /oauth2/getCaptcha: get: consumes: diff --git a/dsSso/main.go b/dsSso/main.go index 72b22ec9..2b257b82 100644 --- a/dsSso/main.go +++ b/dsSso/main.go @@ -67,7 +67,7 @@ func startOAuth2Server() { // @title 东师理想统一认证中心(OAuth2+Sso) // @version 2.0 // @description 参考自xxl-sso -// @host 127.0.0.1:8000 +// @host 10.10.14.187:8000 func main() { // 发布模式 //gin.SetMode(gin.ReleaseMode) diff --git a/dsSso/static/jumpWx.html b/dsSso/static/jumpWx.html index fc72bd18..2d4e770a 100644 --- a/dsSso/static/jumpWx.html +++ b/dsSso/static/jumpWx.html @@ -25,10 +25,20 @@ success: function (result) { var open_id = Base64.encode(aesEncrypt(result.openid)); if (result.success) { - alert("接下来要判断是不是此openId在数据库中已经完成了账号绑定,如果完成了,直接模拟登录;如果没有完成,需要进入绑定界面。") - //window.location.href ="/sso/static/bindUser.html?openid="+open_id; + $.ajax({ + type: "GET", + dataType: "json", + url: "/oauth2/checkOpenId", + data: { + "openid": open_id + }, + async: false, + success: function (result) { + + } + }); } else { - //window.location.href = "bindUser.html?open_id="+open_id+"&type_id="+aesEncrypt("2")+"&redirect_url="+default_redirect_url; + alert("code不合法!"); } } });