master
huanghai 5 years ago
parent 1116203341
commit 7d5cb4fcee

@ -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 {

@ -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)",

@ -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)",

@ -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:

@ -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)

@ -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不合法");
}
}
});

Loading…
Cancel
Save