Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
fefb0d0c
提交
fefb0d0c
编写于
6月 21, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/master'
上级
c07b29c3
0ea5f602
变更
14
隐藏空白字符变更
内嵌
并排
正在显示
14 个修改的文件
包含
1038 行增加
和
98 行删除
+1038
-98
dingdingRedirect.html
app_web/public/assets/dingdingRedirect.html
+89
-0
QQ.svg
app_web/public/assets/img/QQ.svg
+1
-1
dingding.svg
app_web/public/assets/img/dingding.svg
+1
-0
weixin.svg
app_web/public/assets/img/weixin.svg
+1
-1
qqRedirect.html
app_web/public/assets/qqRedirect.html
+88
-0
weixinRedirect.html
app_web/public/assets/weixinRedirect.html
+88
-0
login.less
app_web/src/components/login/login.less
+6
-5
login.vue
app_web/src/components/login/login.vue
+202
-16
qqLoginRedirect.vue
app_web/src/components/login/qqLoginRedirect.vue
+2
-2
register.vue
app_web/src/components/login/register.vue
+2
-2
index.ts
app_web/src/router/index.ts
+5
-1
DevBootSecurityConfig.java
...rc/main/java/cn/ibizlab/config/DevBootSecurityConfig.java
+11
-1
UserRegisterService.java
...zlab/core/uaa/extensions/service/UserRegisterService.java
+174
-39
UserRegisterResource.java
.../cn/ibizlab/api/rest/extensions/UserRegisterResource.java
+368
-30
未找到文件。
app_web/public/assets/dingdingRedirect.html
0 → 100644
浏览文件 @
fefb0d0c
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1.0"
>
<link
rel=
"icon"
href=
"../favicon.ico"
>
<title>
ibzuaa
</title>
<script
src=
"https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"
></script>
<script>
$
(
function
()
{
var
code
=
getUrlParam
(
'code'
);
var
state
=
getUrlParam
(
'state'
);
// alert("code:" + code + "\n state:" + state);
if
(
code
&&
state
)
{
// 通过授权code请求后台
// alert(window.location.hostname);
var
opt
=
{
"code"
:
code
,
"state"
:
state
};
$
.
ajax
({
type
:
"post"
,
url
:
"../uaa/queryDingtalkUserByCode"
,
dataType
:
"json"
,
data
:
JSON
.
stringify
(
opt
),
contentType
:
'application/json'
,
success
:
function
(
data
)
{
// console.log(JSON.stringify(data));
if
(
data
)
{
if
(
data
.
token
)
{
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
var
ibzuser
=
JSON
.
stringify
(
data
.
ibzuser
);
// 设置cookie,保存账号密码7天
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
// 跳转首页
window
.
location
.
href
=
"../index"
;
}
else
{
// 跳转微信绑定
alert
(
"跳转到微信"
)
window
.
location
.
href
=
"../#/weixinLoginRedirect?code="
+
code
+
"&state="
+
state
;
}
}
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
)
{
alert
(
XMLHttpRequest
.
readyState
+
XMLHttpRequest
.
status
+
XMLHttpRequest
.
responseText
);
// 回到登录页
window
.
location
.
href
=
"../"
;
}
});
}
else
{
alert
(
"微信授权登录失败!"
);
// 回到登录页
window
.
location
.
href
=
"../"
;
}
});
// 获取url中的参数
function
getUrlParam
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
//匹配目标参数
if
(
r
!=
null
)
return
unescape
(
r
[
2
]);
return
null
;
//返回参数值
}
// 设置cookie
function
setCookie
(
loginname
,
password
,
exdays
)
{
// 获取时间
let
exdate
=
new
Date
();
// 保存的天数
exdate
.
setTime
(
exdate
.
getTime
()
+
24
*
60
*
60
*
1000
*
exdays
);
// 字符串拼接cookie
window
.
document
.
cookie
=
"loginname"
+
"="
+
loginname
+
";path=/;expires="
+
exdate
.
toUTCString
();
window
.
document
.
cookie
=
"password"
+
"="
+
password
+
";path=/;expires="
+
exdate
.
toUTCString
();
}
</script>
</head>
<body>
</body>
</html>
app_web/public/assets/img/QQ.svg
浏览文件 @
fefb0d0c
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
class=
"icon"
width=
"200px"
height=
"200.00px"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
><path
d=
"M511.999 1024a512 512 0 1 0-512-512 512 512 0 0 0 512 512z"
fill=
"#23A0F0"
/><path
d=
"M735.765 604.422c-3.55-49.47-36.192-90.932-55.09-112.47a70.383 70.383 0 0 0-15.577-67.003v-1.718c0-97.235-68.028-167.254-153.35-167.55-85.333 0.342-153.35 70.315-153.35 167.55v1.718a70.383 70.383 0 0 0-15.576 67.003c-18.898 21.413-51.54 62.874-55.09 112.47a75.39 75.39 0 0 0 7.554 40.425c7.555 10.308 28.513-2.06 43.406-34.93a210.33 210.33 0 0 0 35.499 67.914c-36.307 8.477-46.729 44.897-34.475 64.853 8.59 14.086 28.445 25.657 62.419 25.657 60.473 0 87.267-16.611 99.18-28.057a16.259 16.259 0 0 1 20.844 0c11.913 11.57 38.684 28.057 99.18 28.057 34.02 0 53.715-11.57 62.419-25.657 12.253-19.922 1.831-56.342-34.475-64.853a211.627 211.627 0 0 0 35.499-67.914c14.893 32.87 35.85 45.124 43.406 34.93a76.493 76.493 0 0 0 7.577-40.425z"
fill=
"#FFFFFF"
/></svg>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t=
"1592560654178"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"17475"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M506.054591 880.192733c0 43.505863-63.615876 78.773088-142.089136 78.773088s-142.089136-35.268248-142.089135-78.773088 63.615876-78.773088 142.089135-78.773088 142.089136 35.268248 142.089136 78.773088z m153.385413-78.773088c-78.474282 0-142.089136 35.268248-142.089136 78.773088s63.615876 78.773088 142.089136 78.773088 142.089136-35.268248 142.089135-78.773088-63.615876-78.773088-142.089135-78.773088z"
fill=
"#FFC817"
p-id=
"17476"
></path><path
d=
"M825.904293 502.377852s-10.752902-11.024078-22.294772-21.221324V355.234607c0-161.052023-130.558521-291.610544-291.610544-291.610544S220.389456 194.182584 220.389456 355.234607v125.921921c-11.540847 10.197246-22.294772 21.221324-22.294772 21.221324-19.024286 28.53694-64.207347 102.256942-64.207348 171.815157s19.024286 81.449034 26.158777 82.043575c6.616698 0.551562 31.131021-6.063089 60.262502-50.654681 39.425941 131.09985 154.970514 226.037083 291.393603 226.037083 136.639007 0 252.337075-95.236038 291.583938-226.658229 29.309536 45.151339 54.020334 51.829436 60.667731 51.275827 7.134491-0.594541 26.158776-12.485359 26.158777-82.043575S844.928578 530.914792 825.904293 502.377852z"
fill=
"#37474F"
p-id=
"17477"
></path><path
d=
"M297.454646 552.317241a375.358947 375.358947 0 0 0-3.473101 51.128471c0 159.245887 99.199303 288.340057 221.567281 288.340057s221.567281-129.09417 221.567281-288.340057a375.522676 375.522676 0 0 0-3.473101-51.128471H297.454646zM435.307294 197.390649c-32.506345 0-58.857503 35.733852-58.857503 79.81379 0 44.079938 26.351158 79.81379 58.857503 79.813791s58.857503-35.733852 58.857502-79.813791c0-44.079938-26.352181-79.81379-58.857502-79.81379z m9.809413 112.660896c-11.82021 0-21.402449-14.639418-21.402449-32.698726s9.582239-32.698726 21.402449-32.698726c11.82021 0 21.402449 14.639418 21.402449 32.698726s-9.582239 32.698726-21.402449 32.698726zM590.476329 197.390649c-32.506345 0-58.857503 35.733852-58.857503 79.81379 0 44.079938 26.351158 79.81379 58.857503 79.813791s58.857503-35.733852 58.857503-79.813791c-0.001023-44.079938-26.352181-79.81379-58.857503-79.81379z m9.93221 82.787518l-0.030699 0.005117c0.001023 0.021489 0.023536 0.033769 0.023536 0.055258 0 0.896416-0.726547 1.622964-1.622964 1.622964-0.738827 0-1.25969-0.544399-1.455141-1.218758l-0.062422 0.00921v0.149403c-3.748371-9.331529-10.383488-15.635095-18.079774-15.635096-7.693216 0-14.325263 6.296403-18.074657 15.620769l-0.059352-0.036839-0.055258-0.012279c-0.264013 0.557702-0.722454 1.00284-1.380441 1.00284a1.647523 1.647523 0 0 1-1.648546-1.648547c0-0.016373 0.017396-0.025583 0.017396-0.040932l-0.035815-0.008186c-0.058328-0.895393-0.166799-1.768273-0.166799-2.688226 0-18.059308 9.582239-32.698726 21.402449-32.698726s21.402449 14.639418 21.402449 32.698726c0 0.966001-0.110517 1.883907-0.173962 2.823302z"
fill=
"#FFFFFF"
p-id=
"17478"
></path><path
d=
"M281.18817 536.26566c-5.350868 26.753317-16.646122 146.845463-11.296277 173.59878s27.855418 22.285562 60.046585 22.591531c31.211862 0.296759 67.774593 8.918114 68.369133-30.320563 0.594541-39.237653 0.594541-116.5249 9.512655-145.06184 8.91709-28.53694-126.632095-20.807908-126.632096-20.807908z"
fill=
"#FF3B30"
p-id=
"17479"
></path><path
d=
"M274.071076 593.588203l125.538181 40.585347c1.089821-30.820959 3.295046-61.368696 8.211009-77.101005 8.918114-28.53694-126.632095-20.807908-126.632096-20.807908-1.948375 9.739828-4.683672 31.851429-7.117094 57.323566z"
fill=
"#DD2C00"
p-id=
"17480"
></path><path
d=
"M512.594541 467.895503c97.846492 0 177.166025-35.671431 177.166025-57.668421 0-16.646122-79.319533-33.887808-177.166025-33.887808-97.845469 0-177.166025 15.458063-177.166026 33.887808 0 20.808932 79.319533 57.668421 177.166026 57.668421z"
fill=
"#FFC817"
p-id=
"17481"
></path><path
d=
"M514.378164 489.298975s112.363114 1.189082 202.13572-36.860512c89.771583-38.048571 88.880283-42.358737 98.689696-42.358737 9.809413 0 21.402449 14.123672 26.307156 39.61116 4.904707 25.487487 10.701736 45.552475-10.255575 58.037834-20.956288 12.484336-158.290119 93.190449-313.012993 93.190449h-7.729032c-154.722874 0-292.056706-80.706113-313.012993-93.190449s-15.160281-32.549324-10.255575-58.037834c4.904707-25.487487 16.497743-39.61116 26.307156-39.61116s8.918114 4.310166 98.689696 42.358737 202.136743 36.860513 202.136744 36.860512z"
fill=
"#FF3B30"
p-id=
"17482"
></path></svg>
\ No newline at end of file
\ No newline at end of file
app_web/public/assets/img/dingding.svg
0 → 100644
浏览文件 @
fefb0d0c
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t=
"1592559616839"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"8348"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M863.168 398.912c-1.568 6.56-5.376 16.16-10.752 27.744h0.128l-0.64 1.088c-31.296 67.072-113.024 198.624-113.024 198.624s-0.096-0.32-0.416-0.8l-23.872 41.6h115.104L609.856 960l49.888-199.2h-90.56l31.456-131.712a1282.24 1282.24 0 0 0-91.2 26.08s-48.224 28.288-138.88-54.4c0 0-61.184-53.952-25.728-67.424 15.104-5.76 73.216-13.024 118.976-19.2 61.792-8.384 99.84-12.8 99.84-12.8s-190.592 2.848-235.808-4.288c-45.216-7.104-102.56-82.656-114.784-149.12 0 0-18.88-36.448 40.64-19.2 59.52 17.28 305.92 67.232 305.92 67.232S239.2 297.568 217.888 273.568c-21.344-24-62.752-131.04-57.376-196.8 0 0 2.336-16.416 19.136-12.032 0 0 236.896 108.448 398.912 167.808 161.984 59.36 302.816 89.536 284.64 166.4z"
fill=
"#3296FA"
p-id=
"8349"
></path></svg>
\ No newline at end of file
app_web/public/assets/img/weixin.svg
浏览文件 @
fefb0d0c
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
class=
"icon"
width=
"200px"
height=
"200.00px"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
><path
fill=
"#36ab60"
d=
"M352.814545 385.396364m-33.512727 0a33.512727 33.512727 0 1 0 67.025455 0 33.512727 33.512727 0 1 0-67.025455 0Z"
/><path
fill=
"#36ab60"
d=
"M502.690909 384.465455m-33.512727 0a33.512727 33.512727 0 1 0 67.025454 0 33.512727 33.512727 0 1 0-67.025454 0Z"
/><path
fill=
"#36ab60"
d=
"M576.232727 534.341818m-23.272727 0a23.272727 23.272727 0 1 0 46.545455 0 23.272727 23.272727 0 1 0-46.545455 0Z"
/><path
fill=
"#36ab60"
d=
"M694.458182 536.203636m-23.272727 0a23.272727 23.272727 0 1 0 46.545454 0 23.272727 23.272727 0 1 0-46.545454 0Z"
/><path
fill=
"#36ab60"
d=
"M512 0C229.003636 0 0 229.003636 0 512s229.003636 512 512 512 512-229.003636 512-512S794.996364 0 512 0z m-87.505455 630.225455c-26.996364 0-48.407273-5.585455-75.403636-11.17091l-75.403636 37.236364 21.410909-64.232727c-53.992727-37.236364-85.643636-85.643636-85.643637-145.221818 0-102.4 96.814545-182.458182 215.04-182.458182 105.192727 0 198.283636 64.232727 216.901819 150.807273-6.516364-0.930909-13.963636-0.930909-20.48-0.93091-102.4 0-182.458182 76.334545-182.458182 170.356364 0 15.825455 2.792727 30.72 6.516363 44.683636-7.447273 0-13.963636 0.930909-20.48 0.93091z m314.647273 75.403636l15.825455 53.992727-58.647273-32.581818c-21.410909 5.585455-42.821818 11.170909-64.232727 11.170909-102.4 0-182.458182-69.818182-182.458182-155.461818s80.058182-155.461818 182.458182-155.461818c96.814545 0 182.458182 69.818182 182.458182 155.461818 0 47.476364-31.650909 90.298182-75.403637 122.88z"
/></svg>
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t=
"1592560800799"
class=
"icon"
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"18353"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M1023 629.6c0-144.8-144.9-262.7-307.5-262.7-172.3 0-307.9 118-307.9 262.7 0 145 135.7 262.7 307.9 262.7 36.1 0 72.5-9.1 108.7-18.2l99.3 54.3-27.3-90.3c72.7-54.6 126.8-126.9 126.8-208.5zM620.2 589.4c-22.7 0-41-18.4-41-41 0-22.7 18.4-41 41-41 22.7 0 41 18.4 41 41s-18.3 41-41 41z m199.3-0.3c-22.7 0-41-18.4-41-41 0-22.7 18.4-41 41-41 22.7 0 41 18.4 41 41 0 22.7-18.4 41-41 41z m0 0"
fill=
"#00C800"
p-id=
"18354"
></path><path
d=
"M362.1 95.3C163.1 95.3 0 231 0 403.2c0 99.5 54.2 181.1 144.9 244.5l-36.2 108.9L235.2 693.1c45.3 8.9 81.6 18.2 126.8 18.2 11.4 0 22.7-0.5 33.8-1.4-7.1-24.2-11.2-49.5-11.2-75.9 0-158.2 135.9-286.6 307.8-286.6 11.8 0 23.4 0.8 34.9 2.2C696.1 203.7 540.1 95.3 362.1 95.3zM240.5 343.7c-27.2 0-49.2-22-49.2-49.2 0-27.2 22-49.2 49.2-49.2 27.2 0 49.2 22 49.2 49.2 0 27.2-22 49.2-49.2 49.2z m252.9 0c-27.2 0-49.2-22-49.2-49.2 0-27.2 22-49.2 49.2-49.2s49.2 22 49.2 49.2c0 27.2-22 49.2-49.2 49.2z m0 0"
fill=
"#00C800"
p-id=
"18355"
></path></svg>
\ No newline at end of file
\ No newline at end of file
app_web/public/assets/qqRedirect.html
0 → 100644
浏览文件 @
fefb0d0c
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1.0"
>
<link
rel=
"icon"
href=
"../favicon.ico"
>
<title>
ibzuaa
</title>
<script
src=
"https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"
></script>
<script>
$
(
function
()
{
var
code
=
getUrlParam
(
'code'
);
var
state
=
getUrlParam
(
'state'
);
alert
(
"code:"
+
code
+
"
\n
state:"
+
state
);
if
(
code
&&
state
)
{
// 通过授权code请求后台
// alert(window.location.hostname);
var
opt
=
{
"code"
:
code
,
"state"
:
state
};
$
.
ajax
({
type
:
"post"
,
url
:
"../uaa/queryQQUserByCode"
,
dataType
:
"json"
,
data
:
JSON
.
stringify
(
opt
),
contentType
:
'application/json'
,
success
:
function
(
data
)
{
// console.log(JSON.stringify(data));
if
(
data
)
{
if
(
data
.
token
)
{
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
var
ibzuser
=
JSON
.
stringify
(
data
.
ibzuser
);
// 设置cookie,保存账号密码7天
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
// 跳转首页
window
.
location
.
href
=
"../index"
;
}
else
{
// 跳转微信绑定
window
.
location
.
href
=
"../#/weixinLoginRedirect?code="
+
code
+
"&state="
+
state
;
}
}
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
)
{
alert
(
XMLHttpRequest
.
readyState
+
XMLHttpRequest
.
status
+
XMLHttpRequest
.
responseText
);
// 回到登录页
window
.
location
.
href
=
"../"
;
}
});
}
else
{
alert
(
"微信授权登录失败!"
);
// 回到登录页
window
.
location
.
href
=
"../"
;
}
});
// 获取url中的参数
function
getUrlParam
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
//匹配目标参数
if
(
r
!=
null
)
return
unescape
(
r
[
2
]);
return
null
;
//返回参数值
}
// 设置cookie
function
setCookie
(
loginname
,
password
,
exdays
)
{
// 获取时间
let
exdate
=
new
Date
();
// 保存的天数
exdate
.
setTime
(
exdate
.
getTime
()
+
24
*
60
*
60
*
1000
*
exdays
);
// 字符串拼接cookie
window
.
document
.
cookie
=
"loginname"
+
"="
+
loginname
+
";path=/;expires="
+
exdate
.
toUTCString
();
window
.
document
.
cookie
=
"password"
+
"="
+
password
+
";path=/;expires="
+
exdate
.
toUTCString
();
}
</script>
</head>
<body>
</body>
</html>
app_web/public/assets/weixinRedirect.html
0 → 100644
浏览文件 @
fefb0d0c
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width,initial-scale=1.0"
>
<link
rel=
"icon"
href=
"../favicon.ico"
>
<title>
ibzuaa
</title>
<script
src=
"https://lib.sinaapp.com/js/jquery/2.0.2/jquery-2.0.2.min.js"
></script>
<script>
$
(
function
()
{
var
code
=
getUrlParam
(
'code'
);
var
state
=
getUrlParam
(
'state'
);
// alert("code:" + code + "\n state:" + state);
if
(
code
&&
state
)
{
// 通过授权code请求后台
// alert(window.location.hostname);
var
opt
=
{
"code"
:
code
,
"state"
:
state
};
$
.
ajax
({
type
:
"post"
,
url
:
"../uaa/queryWechatUserByCode"
,
dataType
:
"json"
,
data
:
JSON
.
stringify
(
opt
),
contentType
:
'application/json'
,
success
:
function
(
data
)
{
// console.log(JSON.stringify(data));
if
(
data
)
{
if
(
data
.
token
)
{
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
if
(
data
.
ibzuser
)
{
var
ibzuser
=
JSON
.
stringify
(
data
.
ibzuser
);
// 设置cookie,保存账号密码7天
setCookie
(
ibzuser
.
loginname
,
ibzuser
.
password
,
7
);
// 跳转首页
window
.
location
.
href
=
"../index"
;
}
else
{
// 跳转微信绑定
window
.
location
.
href
=
"../#/weixinLoginRedirect?code="
+
code
+
"&state="
+
state
;
}
}
},
error
:
function
(
XMLHttpRequest
,
textStatus
,
errorThrown
)
{
alert
(
XMLHttpRequest
.
readyState
+
XMLHttpRequest
.
status
+
XMLHttpRequest
.
responseText
);
// 回到登录页
window
.
location
.
href
=
"../"
;
}
});
}
else
{
alert
(
"微信授权登录失败!"
);
// 回到登录页
window
.
location
.
href
=
"../"
;
}
});
// 获取url中的参数
function
getUrlParam
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
//匹配目标参数
if
(
r
!=
null
)
return
unescape
(
r
[
2
]);
return
null
;
//返回参数值
}
// 设置cookie
function
setCookie
(
loginname
,
password
,
exdays
)
{
// 获取时间
let
exdate
=
new
Date
();
// 保存的天数
exdate
.
setTime
(
exdate
.
getTime
()
+
24
*
60
*
60
*
1000
*
exdays
);
// 字符串拼接cookie
window
.
document
.
cookie
=
"loginname"
+
"="
+
loginname
+
";path=/;expires="
+
exdate
.
toUTCString
();
window
.
document
.
cookie
=
"password"
+
"="
+
password
+
";path=/;expires="
+
exdate
.
toUTCString
();
}
</script>
</head>
<body>
</body>
</html>
app_web/src/components/login/login.less
浏览文件 @
fefb0d0c
...
@@ -100,14 +100,15 @@
...
@@ -100,14 +100,15 @@
}
}
.wx-svg-container,
.wx-svg-container,
.qq-svg-container {
.qq-svg-container,
.dd-svg-container{
display: inline-block;
display: inline-block;
width:
5
0px;
width:
4
0px;
height:
5
0px;
height:
4
0px;
line-height:
5
0px;
line-height:
4
0px;
text-align: center;
text-align: center;
padding-top: 1px;
padding-top: 1px;
border-radius: 4px;
border-radius: 4px;
margin: 10px
3px -20px 7
px;
margin: 10px
5px -20px 15
px;
}
}
app_web/src/components/login/login.vue
浏览文件 @
fefb0d0c
<
template
>
<
template
>
<div
class=
'login'
>
<div
class=
'login'
>
<img
src=
"/assets/img/background.png"
/>
<img
src=
"/assets/img/background.png"
draggable=
"false"
/>
<div
class=
'login-con'
>
<div
class=
'login-con'
>
<card
:bordered=
"false"
>
<card
:bordered=
"false"
>
...
@@ -52,6 +52,9 @@
...
@@ -52,6 +52,9 @@
<div
class=
"sign-btn"
@
click=
"wechatHandleClick('wechat')"
>
<div
class=
"sign-btn"
@
click=
"wechatHandleClick('wechat')"
>
<img
src=
"/assets/img/weixin.svg"
class=
"wx-svg-container"
draggable=
"false"
>
<img
src=
"/assets/img/weixin.svg"
class=
"wx-svg-container"
draggable=
"false"
>
</div>
</div>
<div
class=
"sign-btn"
@
click=
"dingtalkHandleClick('dingtalk')"
>
<img
src=
"/assets/img/dingding.svg"
class=
"dd-svg-container"
draggable=
"false"
>
</div>
</div>
</div>
</form-item>
</form-item>
...
@@ -60,7 +63,8 @@
...
@@ -60,7 +63,8 @@
</card>
</card>
<div
class=
"log_footer"
>
<div
class=
"log_footer"
>
<div
class=
"copyright"
>
<div
class=
"copyright"
>
<a
href=
"https://www.ibizlab.cn/"
target=
"_blank"
>
{{
appTitle
}}
is based on ibizlab .
</a>
<a
href=
"https://www.ibizlab.cn/"
target=
"_blank"
draggable=
"false"
>
{{
appTitle
}}
is based on ibizlab
.
</a>
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -82,7 +86,7 @@
...
@@ -82,7 +86,7 @@
* @type {*}
* @type {*}
* @memberof Login
* @memberof Login
*/
*/
public
form
:
any
=
{
loginname
:
'
ibzadmin
'
,
password
:
'123456'
};
public
form
:
any
=
{
loginname
:
'
guest
'
,
password
:
'123456'
};
/**
/**
...
@@ -127,7 +131,12 @@
...
@@ -127,7 +131,12 @@
}
}
public
mounted
()
{
public
mounted
()
{
this
.
getCookie
(
"loginname"
);
if
(
this
.
getCookie
(
"loginname"
)
&&
this
.
getCookie
(
"loginname"
)
!==
'undefined'
)
{
this
.
form
.
loginname
=
this
.
getCookie
(
"loginname"
);
}
if
(
this
.
getCookie
(
"password"
)
&&
this
.
getCookie
(
"password"
)
!==
'undefined'
)
{
this
.
form
.
password
=
this
.
getCookie
(
"password"
);
}
}
}
/**
/**
...
@@ -232,27 +241,204 @@
...
@@ -232,27 +241,204 @@
* @param thirdpart
* @param thirdpart
*/
*/
public
tencentHandleClick
(
thirdpart
:
any
)
{
public
tencentHandleClick
(
thirdpart
:
any
)
{
this
.
$Message
.
warning
(
"QQ授权登录暂未支持"
);
this
.
$Message
.
warning
(
"QQ授权登录暂未支持,敬请期待"
);
// var _this = this;
return
;
// const client_id = '101885024';// 网站应用appid
// 截取地址,拼接需要部分组成新地址
// const redirect_uri = 'http%3A%2F%2Fh6s33i.natappfree.cc%2F%23%2FqqLoginRedirect';// 回调地址,即授权登录成功后跳转的地址,需要UrlEncode转码
const
baseUrl
=
this
.
getNeedLocation
();
// const state = Math.random().toString(36).substr(2);// 随机生成一段字符串,防止CSRF攻击的
// const url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=' + client_id + '&redirect_uri=' + redirect_uri + "&scope=get_user_info" + "&state=" + state;// qq授权登录地址
// 从后台获取qq互联创建的网站应用appid
// this.openWindow(url, thirdpart, 540, 540);
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/getQQAppId'
);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
if
(
data
&&
data
.
appid
)
{
// 1.qq互联创建的网站应用appid
const
client_id
=
data
.
appid
;
// 2.回调地址,即授权登录成功后跳转的地址,需要UrlEncode转码
const
redirect_uri
=
baseUrl
+
'assets/qqRedirect.html'
;
const
redirect_uri_encode
=
decodeURIComponent
(
redirect_uri
);
// 3.随机生成一段字符串,防止CSRF攻击的
const
state
=
Math
.
random
().
toString
(
36
).
substr
(
2
);
// 4.qq授权登录地址
const
url
=
'https://graph.qq.com/oauth2.0/authorize?response_type=code'
+
'&client_id='
+
client_id
+
'&redirect_uri='
+
redirect_uri_encode
+
"&scope=get_user_info"
+
"&state="
+
state
;
// 5.跳转qq授权
window
.
location
.
href
=
url
;
}
else
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败,"
+
data
.
detail
,
duration
:
5
,
closable
:
true
});
}
}
}).
catch
((
error
:
any
)
=>
{
const
data
=
error
.
data
;
if
(
data
&&
data
.
detail
)
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败,"
+
data
.
detail
,
duration
:
5
,
closable
:
true
});
}
else
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败"
,
duration
:
5
,
closable
:
true
});
}
});
}
}
/**
/**
* 微信授权登录
* 微信授权登录
* @param thirdpart
* @param thirdpart
*/
*/
public
wechatHandleClick
(
thirdpart
:
any
)
{
public
wechatHandleClick
(
thirdpart
:
any
)
{
this
.
$Message
.
warning
(
"微信授权登录暂未支持"
);
// this.$Message.warning("微信授权登录暂未支持,敬请期待");
// let appId = 'wxcfe83301b6e6615f'; //微信开放平台提供的appId
// let redirectURI = 'http%3A%2F%2Fh6s33i.natappfree.cc%2F%23%2FweixinLoginRedirect'; //微信扫码后回调地址,需要UrlEncode转码
// 从后台获取微信开放平台提供的appid
// let url = 'https://open.weixin.qq.com/connect/qrconnect?appid=' + appId + '&redirect_uri=' + redirectURI + '&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect';//微信扫码url
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/getWechatAppId'
);
// this.openWindow(url, thirdpart, 540, 540);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
if
(
data
&&
data
.
appid
)
{
// 截取地址,拼接需要部分组成新地址
const
baseUrl
=
this
.
getNeedLocation
();
// 1.微信开放平台提供的appId
const
appId
=
data
.
appid
;
// 2.微信扫码后回调地址,需要UrlEncode转码
const
redirect_uri
=
baseUrl
+
'assets/weixinRedirect.html'
;
const
redirect_uri_encode
=
encodeURIComponent
(
redirect_uri
);
// 3.微信扫码url
const
url
=
'https://open.weixin.qq.com/connect/qrconnect?response_type=code'
+
'&appid='
+
appId
+
'&redirect_uri='
+
redirect_uri_encode
+
'&scope=snsapi_login'
+
'&state=STATE'
;
// 4.跳转微信扫码
window
.
location
.
href
=
url
;
}
else
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败,"
+
data
.
detail
,
duration
:
5
,
closable
:
true
});
}
}
}).
catch
((
error
:
any
)
=>
{
const
data
=
error
.
data
;
if
(
data
&&
data
.
detail
)
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败,"
+
data
.
detail
,
duration
:
5
,
closable
:
true
});
}
else
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败"
,
duration
:
5
,
closable
:
true
});
}
});
}
/**
* 钉钉授权登录
* @param thirdpart
*/
public
dingtalkHandleClick
(
thirdpart
:
any
)
{
// this.$Message.warning("钉钉授权登录暂未支持,敬请期待");
// return;
// 从后台获取钉钉开放平台提供的appid
const
get
:
Promise
<
any
>
=
this
.
$http
.
get
(
'/uaa/getDingtalkAppId'
);
get
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
if
(
data
&&
data
.
appid
)
{
// 截取地址,拼接需要部分组成新地址
const
baseUrl
=
this
.
getNeedLocation
();
// 1.钉钉开放平台提供的appId
const
appId
=
data
.
appid
;
// 2.钉钉扫码后回调地址,需要UrlEncode转码
const
redirect_uri
=
baseUrl
+
'assets/dingdingRedirect.html'
;
const
redirect_uri_encode
=
encodeURIComponent
(
redirect_uri
);
// 3.钉钉扫码url
const
url
=
'https://oapi.dingtalk.com/connect/qrconnect?response_type=code'
+
'&appid='
+
appId
+
'&redirect_uri='
+
redirect_uri_encode
+
'&scope=snsapi_login'
+
'&state=STATE'
;
// 4.跳转钉钉扫码
window
.
location
.
href
=
url
;
}
else
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败,"
+
data
.
detail
,
duration
:
5
,
closable
:
true
});
}
}
}).
catch
((
error
:
any
)
=>
{
const
data
=
error
.
data
;
if
(
data
&&
data
.
detail
)
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败,"
+
data
.
detail
,
duration
:
5
,
closable
:
true
});
}
else
{
this
.
$Message
.
error
({
content
:
"获取网站应用appid失败"
,
duration
:
5
,
closable
:
true
});
}
});
}
}
/**
* 获取需要的location部分
*/
public
getNeedLocation
()
{
// 截取地址,拼接需要部分组成新地址
const
scheme
=
window
.
location
.
protocol
;
const
host
=
window
.
location
.
host
;
let
baseUrl
:
any
;
baseUrl
=
scheme
+
"//"
+
host
;
const
port
=
window
.
location
.
port
;
console
.
log
(
"scheme:"
+
scheme
);
console
.
log
(
"host:"
+
host
);
console
.
log
(
"port:"
+
port
);
if
(
port
)
{
if
(
port
==
'80'
||
port
==
'443'
)
{
baseUrl
+=
"/"
;
}
else
{
baseUrl
+=
":"
+
port
+
"/"
;
}
}
else
{
baseUrl
+=
"/"
;
}
console
.
log
(
baseUrl
);
return
baseUrl
;
}
/**
/**
* 打开一个新窗口
* 打开一个新窗口
* @param url 链接地址
* @param url 链接地址
...
...
app_web/src/components/login/qqLoginRedirect.vue
浏览文件 @
fefb0d0c
<
template
>
<
template
>
<div
class=
'login'
>
<div
class=
'login'
>
<img
src=
"/assets/img/background.png"
/>
<img
src=
"/assets/img/background.png"
draggable=
"false"
/>
<div
class=
'login-con'
>
<div
class=
'login-con'
>
<card
:bordered=
"false"
>
<card
:bordered=
"false"
>
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
</card>
</card>
<div
class=
"log_footer"
>
<div
class=
"log_footer"
>
<div
class=
"copyright"
>
<div
class=
"copyright"
>
<a
href=
"https://www.ibizlab.cn/"
target=
"_blank"
>
{{
appTitle
}}
is based on ibizlab .
</a>
<a
href=
"https://www.ibizlab.cn/"
target=
"_blank"
draggable=
"false"
>
{{
appTitle
}}
is based on ibizlab .
</a>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
app_web/src/components/login/register.vue
浏览文件 @
fefb0d0c
<
template
>
<
template
>
<div
class=
'login'
>
<div
class=
'login'
>
<img
src=
"/assets/img/background.png"
/>
<img
src=
"/assets/img/background.png"
draggable=
"false"
/>
<div
class=
'login-con'
>
<div
class=
'login-con'
>
<card
:bordered=
"false"
>
<card
:bordered=
"false"
>
...
@@ -62,7 +62,7 @@
...
@@ -62,7 +62,7 @@
</card>
</card>
<div
class=
"log_footer"
>
<div
class=
"log_footer"
>
<div
class=
"copyright"
>
<div
class=
"copyright"
>
<a
href=
"https://www.ibizlab.cn/"
target=
"_blank"
>
{{
appTitle
}}
is based on ibizlab .
</a>
<a
href=
"https://www.ibizlab.cn/"
target=
"_blank"
draggable=
"false"
>
{{
appTitle
}}
is based on ibizlab .
</a>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
app_web/src/router/index.ts
浏览文件 @
fefb0d0c
...
@@ -7,7 +7,11 @@ export const globalRoutes:Array<any> = [
...
@@ -7,7 +7,11 @@ export const globalRoutes:Array<any> = [
{
{
path
:
'/qqLoginRedirect'
,
path
:
'/qqLoginRedirect'
,
component
:
()
=>
import
(
'@components/login/qqLoginRedirect.vue'
)
component
:
()
=>
import
(
'@components/login/qqLoginRedirect.vue'
)
}
},
{
path
:
'/weixinLoginRedirect'
,
component
:
()
=>
import
(
'@components/login/weixinLoginRedirect.vue'
),
},
];
];
//用户自定义首页路由
//用户自定义首页路由
export
const
indexRoutes
:
Array
<
any
>
=
[
export
const
indexRoutes
:
Array
<
any
>
=
[
...
...
ibzuaa-boot/src/main/java/cn/ibizlab/config/DevBootSecurityConfig.java
浏览文件 @
fefb0d0c
...
@@ -106,8 +106,18 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -106,8 +106,18 @@ public class DevBootSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/syspssystems/save"
).
permitAll
()
.
antMatchers
(
"/syspssystems/save"
).
permitAll
()
.
antMatchers
(
"/uaa/login"
).
permitAll
()
.
antMatchers
(
"/uaa/login"
).
permitAll
()
.
antMatchers
(
"/uaa/register"
).
permitAll
()
.
antMatchers
(
"/uaa/register"
).
permitAll
()
.
antMatchers
(
"/uaa/queryUserByOpenId"
).
permitAll
()
.
antMatchers
(
"/uaa/thirdPartRegister"
).
permitAll
()
.
antMatchers
(
"/uaa/responseTokenToWeiXin"
).
permitAll
()
.
antMatchers
(
"/uaa/responseTokenToWeiXin"
).
permitAll
()
.
antMatchers
(
"/uaa/getWechatAppId"
).
permitAll
()
.
antMatchers
(
"/uaa/queryWechatUserByCode"
).
permitAll
()
.
antMatchers
(
"/uaa/getWechatUserInfoByCode"
).
permitAll
()
.
antMatchers
(
"/uaa/getDingtalkAppId"
).
permitAll
()
.
antMatchers
(
"/uaa/queryDingtalkUserByCode"
).
permitAll
()
.
antMatchers
(
"/uaa/queryQQUserByCode"
).
permitAll
()
.
antMatchers
(
"/uaa/getQQAppId"
).
permitAll
()
.
anyRequest
().
authenticated
()
.
anyRequest
().
authenticated
()
// 防止iframe 造成跨域
// 防止iframe 造成跨域
.
and
().
headers
().
frameOptions
().
disable
();
.
and
().
headers
().
frameOptions
().
disable
();
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/UserRegisterService.java
浏览文件 @
fefb0d0c
...
@@ -5,35 +5,45 @@ import cn.ibizlab.util.errors.BadRequestAlertException;
...
@@ -5,35 +5,45 @@ import cn.ibizlab.util.errors.BadRequestAlertException;
import
cn.ibizlab.util.helper.HttpUtils
;
import
cn.ibizlab.util.helper.HttpUtils
;
import
cn.ibizlab.util.service.IBZUSERService
;
import
cn.ibizlab.util.service.IBZUSERService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.nacos.client.identify.Base64
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.crypto.Mac
;
import
javax.crypto.spec.SecretKeySpec
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
/**
/**
* 实体[IBZUSER] 用户注册接口实现
* 实体[IBZUSER] 用户注册接口实现
*/
*/
@Service
@Service
@Slf4j
@Slf4j
public
class
UserRegisterService
{
public
class
UserRegisterService
{
@Autowired
@Autowired
private
IBZUSERService
ibzuserService
;
private
IBZUSERService
ibzuserService
;
@Value
(
"${ibiz.auth.qq.app_id:}"
)
private
String
app_ID
;
@Value
(
"${ibiz.auth.qq.userinfo_uri:}"
)
private
String
getUserInfoURL
;
/**
/**
* 普通注册
* 注册
*
* @param ibzuser
* @param ibzuser
* @return
* @return
*/
*/
public
IBZUSER
commom
Register
(
IBZUSER
ibzuser
)
{
public
IBZUSER
to
Register
(
IBZUSER
ibzuser
)
{
// 创建ibzuser
// 创建ibzuser
boolean
flag
=
ibzuserService
.
save
(
ibzuser
);
boolean
flag
=
ibzuserService
.
save
(
ibzuser
);
if
(!
flag
)
{
if
(!
flag
)
{
...
@@ -44,42 +54,167 @@ public class UserRegisterService{
...
@@ -44,42 +54,167 @@ public class UserRegisterService{
/**
/**
* qq授权注册
* 通过code获取微信用户信息
* @param ibzuser
*
* @param openId 用户身份的唯一标识
* @param code
* @param accessToken 当前用户在此网站/应用的登录状态与授权信息
* @param state
* @param wechatAppId
* @param wechatappsecret
* @return
*/
*/
public
IBZUSER
qqRegister
(
IBZUSER
ibzuser
,
String
openId
,
String
accessToken
)
{
public
JSONObject
requestWechatUserByCode
(
String
code
,
String
state
,
String
wechatAppId
,
String
wechatappsecret
)
{
// 根据OpenID获取该QQ用户的相关信息
JSONObject
returnObj
=
null
;
try
{
try
{
// 请求参数进行URL编码
// 1.根据code获取access_token
String
openIdEncode
=
URLEncoder
.
encode
(
openId
,
"UTF-8"
);
String
getAccessTokenUrl
=
"https://api.weixin.qq.com/sns/oauth2/access_token?appid="
+
wechatAppId
+
"&secret="
+
wechatappsecret
+
"&code="
+
code
+
"&grant_type=authorization_code"
;
String
accessTokenEncode
=
URLEncoder
.
encode
(
accessToken
,
"UTF-8"
);
JSONObject
responseObj
=
JSONObject
.
parseObject
(
HttpUtils
.
get
(
getAccessTokenUrl
,
null
,
null
));
String
url
=
getUserInfoURL
;
if
(!
responseObj
.
containsKey
(
"access_token"
)
&&
!
responseObj
.
containsKey
(
"openid"
))
{
JSONObject
getParamMap
=
new
JSONObject
();
throw
new
BadRequestAlertException
(
"获取access_token失败!"
,
"UserRegisterService"
,
""
);
getParamMap
.
put
(
"access_token"
,
accessToken
);
}
getParamMap
.
put
(
"oauth_consumer_key"
,
app_ID
);
String
access_token
=
responseObj
.
getString
(
"access_token"
);
getParamMap
.
put
(
"openid"
,
openId
);
String
openid
=
responseObj
.
getString
(
"openid"
);
getParamMap
.
put
(
"format"
,
"json"
);
String
refresh_token
=
responseObj
.
getString
(
"refresh_token"
);
// 将参数进行urlencode编码并发送get请求
String
responseStr
=
HttpUtils
.
get
(
url
,
null
,
getParamMap
);
// 2.检验授权凭证(access_token)是否有效
JSONObject
responseObj
=
JSONObject
.
parseObject
(
responseStr
);
String
checkAccessTokenUrl
=
"https://api.weixin.qq.com/sns/auth?access_token="
+
access_token
+
"&openid="
+
responseObj
.
get
(
"openid"
);
// 获取qq用户信息成功
JSONObject
responseObj2
=
JSONObject
.
parseObject
(
HttpUtils
.
get
(
checkAccessTokenUrl
,
null
,
null
));
if
(
responseObj
.
getInteger
(
"ret"
)==
0
)
{
if
(
responseObj2
.
getInteger
(
"errcode"
)
!=
0
)
{
ibzuser
.
setUsername
(
responseObj
.
getString
(
"nickname"
));
// access_token已失效,使用refresh_token进行刷新
}
else
{
String
refreshAccess_token
=
"https://api.weixin.qq.com/sns/oauth2/refresh_token?appid="
+
wechatAppId
+
"&grant_type=refresh_token&refresh_token="
+
refresh_token
;
throw
new
BadRequestAlertException
(
responseObj
.
getString
(
"msg"
),
""
,
""
);
JSONObject
responseObj3
=
JSONObject
.
parseObject
(
HttpUtils
.
get
(
refreshAccess_token
,
null
,
null
));
if
(!
responseObj3
.
containsKey
(
"access_token"
)
||
!
responseObj3
.
containsKey
(
"openid"
))
{
throw
new
BadRequestAlertException
(
"重新获取access_token失败!"
,
"UserRegisterService"
,
""
);
}
openid
=
responseObj3
.
getString
(
"openid"
);
access_token
=
responseObj3
.
getString
(
"access_token"
);
}
// 3.access_token有效,拉取用户信息(需scope为 snsapi_userinfo)
String
getweChatUserInfoUrl
=
"https://api.weixin.qq.com/sns/userinfo?access_token="
+
access_token
+
"&openid="
+
openid
+
"&lang=zh_CN"
;
returnObj
=
JSONObject
.
parseObject
(
HttpUtils
.
get
(
getweChatUserInfoUrl
,
null
,
null
));
if
(
StringUtils
.
isEmpty
(
returnObj
)
||
returnObj
.
containsKey
(
"errcode"
))
{
throw
new
BadRequestAlertException
(
"拉取微信用户信息失败!"
,
"UserRegisterService"
,
""
);
}
}
}
catch
(
UnsupportedEncodingException
e
)
{
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
BadRequestAlertException
(
"获取
QQ用户相关信息失败!"
,
"UserRegisterService-qqRegister"
,
""
);
throw
new
BadRequestAlertException
(
"获取
微信授权用户相关信息失败!"
,
"UserRegisterService"
,
""
);
}
}
// 保存qq授权用户的唯一标识
ibzuser
.
setAvatar
(
openId
);
return
returnObj
;
// 创建ibzuser,注册
}
boolean
flag
=
ibzuserService
.
save
(
ibzuser
);
if
(
flag
)
{
return
ibzuser
;
/**
* 通过code获取qq用户信息
*
* @param code
* @param qqRedirectUri
* @param qqAppId
* @param qqAppKey
* @return
*/
public
JSONObject
requestQQUserByCode
(
String
code
,
String
qqRedirectUri
,
String
qqAppId
,
String
qqAppKey
)
{
JSONObject
returnObj
=
null
;
try
{
// 1.根据code获取access_token
String
getAccessTokenUrl
=
"https://graph.qq.com/oauth2.0/token?client_id="
+
qqAppId
+
"&client_secret="
+
qqAppKey
+
"&code="
+
code
+
"&redirect_uri="
+
qqRedirectUri
+
"&grant_type=authorization_code"
;
JSONObject
responseObj
=
JSONObject
.
parseObject
(
HttpUtils
.
get
(
getAccessTokenUrl
,
null
,
null
));
if
(!
responseObj
.
containsKey
(
"access_token"
))
{
throw
new
BadRequestAlertException
(
"获取access_token失败!"
,
"UserRegisterService"
,
""
);
}
String
access_token
=
responseObj
.
getString
(
"access_token"
);
String
refresh_token
=
responseObj
.
getString
(
"refresh_token"
);
// 2.权限自动续期,获取access_token
String
refreshAccessTokenUrl
=
"https://graph.qq.com/oauth2.0/token?client_id="
+
qqAppId
+
"&client_secret="
+
qqAppKey
+
"&refresh_token="
+
refresh_token
+
"&grant_type=refresh_token"
;
JSONObject
responseObj2
=
JSONObject
.
parseObject
(
HttpUtils
.
get
(
refreshAccessTokenUrl
,
null
,
null
));
if
(
responseObj2
.
containsKey
(
"code"
))
{
throw
new
BadRequestAlertException
(
"续期access_token失败!"
,
"UserRegisterService"
,
""
);
}
else
{
access_token
=
responseObj2
.
getString
(
"access_token"
);
refresh_token
=
responseObj2
.
getString
(
"refresh_token"
);
}
// 3.access_token有效,获取openid
String
getOpenidUrl
=
"https://graph.qq.com/oauth2.0/me?access_token="
+
access_token
;
JSONObject
responseObj3
=
JSONObject
.
parseObject
(
HttpUtils
.
get
(
getOpenidUrl
,
null
,
null
));
if
(
responseObj3
.
containsKey
(
"code"
))
{
throw
new
BadRequestAlertException
(
"拉取qq用户信息失败!"
,
"UserRegisterService"
,
""
);
}
String
openid
=
responseObj3
.
getString
(
"openid"
);
// 4.使用access Token以及openid来访问和修改用户数据
String
getQQUserInfoUrl
=
"https://graph.qq.com/user/get_user_info?access_token="
+
access_token
+
"&oauth_consumer_key="
+
qqAppId
+
"&openid="
+
openid
;
returnObj
=
JSONObject
.
parseObject
(
HttpUtils
.
get
(
getQQUserInfoUrl
,
null
,
null
));
if
(
returnObj
.
containsKey
(
"ret"
)
&&
returnObj
.
getInteger
(
"ret"
)!=
0
)
{
throw
new
BadRequestAlertException
(
"拉取qq用户信息失败!"
,
"UserRegisterService"
,
""
);
}
returnObj
.
put
(
"openid"
,
openid
);
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
BadRequestAlertException
(
"获取qq授权用户相关信息失败!"
,
"UserRegisterService"
,
""
);
}
return
returnObj
;
}
/**
* 钉钉服务端通过临时授权码code获取授权用户的个人信息
* @param code
* @param currentTimeMillis
* @param dingTalkAppId
* @param dingTalkAppSecret
* @return
*/
public
JSONObject
requestDingtalkUserByCode
(
String
code
,
long
currentTimeMillis
,
String
dingTalkAppId
,
String
dingTalkAppSecret
)
{
JSONObject
returnObj
=
null
;
try
{
// 1.根据timestamp, appSecret计算签名值
String
stringToSign
=
String
.
valueOf
(
currentTimeMillis
);
Mac
mac
=
Mac
.
getInstance
(
"HmacSHA256"
);
mac
.
init
(
new
SecretKeySpec
(
dingTalkAppSecret
.
getBytes
(
"UTF-8"
),
"HmacSHA256"
));
byte
[]
signatureBytes
=
mac
.
doFinal
(
stringToSign
.
getBytes
(
"UTF-8"
));
String
signature
=
new
String
(
Base64
.
encodeBase64
(
signatureBytes
));
String
urlEncodeSignature
=
URLEncoder
.
encode
(
signature
,
"UTF-8"
);
// 2.通过临时授权码Code获取用户信息,临时授权码只能使用一次
String
url
=
"https://oapi.dingtalk.com/sns/getuserinfo_bycode?accessKey="
+
dingTalkAppId
+
"×tamp="
+
String
.
valueOf
(
currentTimeMillis
)
+
"&signature="
+
urlEncodeSignature
;
// 创建httpclient对象
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
// 创建post方式请求对象
HttpPost
httpPost
=
new
HttpPost
(
url
);
// 装填参数
JSONObject
param
=
new
JSONObject
();
param
.
put
(
"tmp_auth_code"
,
code
);
StringEntity
jsonBody
=
new
StringEntity
(
param
.
toString
(),
"UTF-8"
);
// 设置参数到请求对象中
httpPost
.
setEntity
(
jsonBody
);
// 设置header信息
httpPost
.
setHeader
(
"Content-type"
,
"application/json"
);
httpPost
.
setHeader
(
"User-Agent"
,
"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"
);
//执行请求操作,并拿到结果(同步阻塞)
CloseableHttpResponse
response
=
client
.
execute
(
httpPost
);
//获取结果实体
HttpEntity
entity
=
response
.
getEntity
();
JSONObject
entityJson
=
null
;
if
(
entity
!=
null
)
{
//按指定编码转换结果实体为String类型
entityJson
=
JSONObject
.
parseObject
(
EntityUtils
.
toString
(
entity
,
"UTF-8"
));
}
if
(
entityJson
.
containsKey
(
"user_info"
))
{
returnObj
=
entityJson
.
getJSONObject
(
"user_info"
);
}
else
{
throw
new
BadRequestAlertException
(
"code获取钉钉用户信息失败"
,
"UserRegisterService"
,
""
);
}
}
catch
(
NoSuchAlgorithmException
|
InvalidKeyException
|
IOException
e
)
{
throw
new
BadRequestAlertException
(
"钉钉生成安全签名失败"
,
"UserRegisterService"
,
""
);
}
}
return
null
;
return
returnObj
;
}
}
}
}
\ No newline at end of file
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/UserRegisterResource.java
浏览文件 @
fefb0d0c
...
@@ -4,12 +4,20 @@ import cn.ibizlab.core.uaa.extensions.service.UserRegisterService;
...
@@ -4,12 +4,20 @@ import cn.ibizlab.core.uaa.extensions.service.UserRegisterService;
import
cn.ibizlab.core.uaa.service.ISysPSSystemService
;
import
cn.ibizlab.core.uaa.service.ISysPSSystemService
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.security.AuthTokenUtil
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
cn.ibizlab.util.service.AuthenticationUserService
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -25,10 +33,43 @@ public class UserRegisterResource {
...
@@ -25,10 +33,43 @@ public class UserRegisterResource {
private
UserRegisterService
userRegisterService
;
private
UserRegisterService
userRegisterService
;
@Autowired
@Autowired
private
ISysPSSystemService
iSysPSSystemService
;
private
ISysPSSystemService
iSysPSSystemService
;
@Autowired
private
AuthTokenUtil
jwtTokenUtil
;
@Autowired
@Qualifier
(
"UAAUserService"
)
private
AuthenticationUserService
userDetailsService
;
@Value
(
"${ibiz.auth.qq.appid:101881963}"
)
private
String
qqAppId
;
// qq互联appid
@Value
(
"${ibiz.auth.qq.appkey:}"
)
private
String
qqAppKey
;
// qq互联appkey
@Value
(
"${ibiz.auth.qq.redirect_uri:}"
)
private
String
qqRedirectUri
;
// qq互联应用回调地址
@Value
(
"${ibiz.auth.wechat.appID:wx4a7473ac9c617f76}"
)
private
String
wechatAppId
;
// 微信开放平台appid
@Value
(
"${ibiz.auth.wechat.appsecret:c2b308b9245dffa316b049840fd81a79}"
)
private
String
wechatappsecret
;
// 微信开放平台appsecret
@Value
(
"${ibiz.auth.wechat.openid:}"
)
private
String
Avatar
;
@Value
(
"${ibiz.auth.wechat.nickname:}"
)
private
String
Nickname
;
@Value
(
"${ibiz.auth.dingding.appid:dingoatysxi5rpbluqgzpk}"
)
private
String
dingTalkAppId
;
@Value
(
"${ibiz.auth.dingding.appid:z2SuCSciWQJ6VSFX8jvHzTF0G_rEmHpjHrZct0rGnWrLyl8cZiRny72244EvF4SO}"
)
private
String
dingTalkAppSecret
;
@Value
(
"${ibiz.auth.qq.redirect_uri:http://127.0.0.1:8111/#/qqLoginRedirect}"
)
private
String
redirect_URI
;
public
static
final
String
TOKEN
=
"weixin"
;
// 这里的token要和微信公众测试号网页填写的token一致
/**
* 普通注册
*
* @param param
* @return
*/
@PostMapping
(
value
=
"/uaa/register"
)
@PostMapping
(
value
=
"/uaa/register"
)
public
ResponseEntity
<
JSONObject
>
register
(
@RequestBody
JSONObject
param
)
{
public
ResponseEntity
<
JSONObject
>
register
(
@RequestBody
JSONObject
param
)
{
JSONObject
object
=
new
JSONObject
();
JSONObject
object
=
new
JSONObject
();
...
@@ -38,13 +79,13 @@ public class UserRegisterResource {
...
@@ -38,13 +79,13 @@ public class UserRegisterResource {
String
password
=
param
.
getString
(
"password"
);
String
password
=
param
.
getString
(
"password"
);
String
registerType
=
param
.
getString
(
"registerType"
);
String
registerType
=
param
.
getString
(
"registerType"
);
if
(
StringUtils
.
isEmpty
(
loginname
))
if
(
StringUtils
.
isEmpty
(
loginname
))
throw
new
BadRequestAlertException
(
"用户名为空"
,
"
register
"
,
""
);
throw
new
BadRequestAlertException
(
"用户名为空"
,
"
UserRegisterResource
"
,
""
);
if
(
StringUtils
.
isEmpty
(
personname
)
&&
(!
"qq"
.
equals
(
registerType
)
&&
!
"we
ixin
"
.
equals
(
registerType
)))
if
(
StringUtils
.
isEmpty
(
personname
)
&&
(!
"qq"
.
equals
(
registerType
)
&&
!
"we
chat
"
.
equals
(
registerType
)))
throw
new
BadRequestAlertException
(
"用户姓名为空"
,
"
register
"
,
""
);
throw
new
BadRequestAlertException
(
"用户姓名为空"
,
"
UserRegisterResource
"
,
""
);
if
(
StringUtils
.
isEmpty
(
password
))
if
(
StringUtils
.
isEmpty
(
password
))
throw
new
BadRequestAlertException
(
"密码为空"
,
"
register
"
,
""
);
throw
new
BadRequestAlertException
(
"密码为空"
,
"
UserRegisterResource
"
,
""
);
if
(
StringUtils
.
isEmpty
(
registerType
))
if
(
StringUtils
.
isEmpty
(
registerType
))
throw
new
BadRequestAlertException
(
"注册方式为空"
,
"
register
"
,
""
);
throw
new
BadRequestAlertException
(
"注册方式为空"
,
"
UserRegisterResource
"
,
""
);
// 检查用户名是否已被注册
// 检查用户名是否已被注册
String
sql
=
"select loginname from ibzuser where loginname=#{et.loginname}"
;
String
sql
=
"select loginname from ibzuser where loginname=#{et.loginname}"
;
...
@@ -52,7 +93,7 @@ public class UserRegisterResource {
...
@@ -52,7 +93,7 @@ public class UserRegisterResource {
sqlParam
.
put
(
"loginname"
,
loginname
);
sqlParam
.
put
(
"loginname"
,
loginname
);
List
<
JSONObject
>
select
=
iSysPSSystemService
.
select
(
sql
,
sqlParam
);
List
<
JSONObject
>
select
=
iSysPSSystemService
.
select
(
sql
,
sqlParam
);
if
(
select
.
size
()
>
0
)
if
(
select
.
size
()
>
0
)
throw
new
BadRequestAlertException
(
"该用户名已被注册"
,
"
register
"
,
""
);
throw
new
BadRequestAlertException
(
"该用户名已被注册"
,
"
UserRegisterResource
"
,
""
);
// 注册
// 注册
IBZUSER
ibzuser
=
new
IBZUSER
();
IBZUSER
ibzuser
=
new
IBZUSER
();
...
@@ -60,27 +101,326 @@ public class UserRegisterResource {
...
@@ -60,27 +101,326 @@ public class UserRegisterResource {
ibzuser
.
setPersonname
(
personname
);
ibzuser
.
setPersonname
(
personname
);
ibzuser
.
setPassword
(
password
);
ibzuser
.
setPassword
(
password
);
ibzuser
.
setLoginname
(
loginname
);
ibzuser
.
setLoginname
(
loginname
);
switch
(
registerType
)
{
ibzuser
.
setUserid
(
"commom-"
+
uuid
);
case
"commom"
:
// 普通注册
userRegisterService
.
toRegister
(
ibzuser
);
ibzuser
.
setUserid
(
"commom-"
+
uuid
);
userRegisterService
.
commomRegister
(
ibzuser
);
// 响应结果
break
;
case
"qq"
:
// qq授权注册
ibzuser
=
null
;
// ibzuser.setUserid("qq-" + uuid);
// String openId = param.getString("openId");
// String accessToken = param.getString("accessToken");
// userRegisterService.qqRegister(ibzuser, openId, accessToken);
break
;
default
:
ibzuser
.
setUserid
(
"commom-"
+
uuid
);
userRegisterService
.
commomRegister
(
ibzuser
);
break
;
}
object
.
put
(
"ibzuser"
,
ibzuser
);
object
.
put
(
"ibzuser"
,
ibzuser
);
return
ResponseEntity
.
ok
().
body
(
object
);
return
ResponseEntity
.
ok
().
body
(
object
);
}
}
/**
* 第三方注册:qq、微信
*
* @param param
* @return
*/
@PostMapping
(
value
=
"/uaa/thirdPartRegister"
)
public
ResponseEntity
<
JSONObject
>
thirdPartRegister
(
@RequestBody
JSONObject
param
)
{
JSONObject
object
=
new
JSONObject
();
// 空校验
String
loginname
=
param
.
getString
(
"loginname"
);
String
password
=
param
.
getString
(
"password"
);
String
registerType
=
param
.
getString
(
"registerType"
);
String
code
=
param
.
getString
(
"wechatCode"
);
System
.
out
.
println
(
"code:"
+
code
);
String
state
=
param
.
getString
(
"wechatState"
);
System
.
out
.
println
(
"state:"
+
state
);
String
avatar
=
param
.
getString
(
"avatar"
);
if
(
StringUtils
.
isEmpty
(
avatar
))
{
avatar
=
Avatar
;
}
System
.
out
.
println
(
"avatar:"
+
avatar
);
String
nickname
=
param
.
getString
(
"nickname"
);
if
(
StringUtils
.
isEmpty
(
nickname
))
{
nickname
=
Nickname
;
}
System
.
out
.
println
(
"nickname:"
+
nickname
);
if
(
StringUtils
.
isEmpty
(
loginname
))
throw
new
BadRequestAlertException
(
"用户名为空"
,
"UserRegisterResource"
,
""
);
if
(
StringUtils
.
isEmpty
(
password
))
throw
new
BadRequestAlertException
(
"密码为空"
,
"UserRegisterResource"
,
""
);
if
(
StringUtils
.
isEmpty
(
registerType
))
throw
new
BadRequestAlertException
(
"注册方式为空"
,
"UserRegisterResource"
,
""
);
if
(
StringUtils
.
isEmpty
(
code
))
throw
new
BadRequestAlertException
(
"微信授权code为空"
,
"UserRegisterResource"
,
""
);
if
(
StringUtils
.
isEmpty
(
state
))
throw
new
BadRequestAlertException
(
"微信授权state为空"
,
"UserRegisterResource"
,
""
);
// 检查用户名是否已被注册
String
sql
=
"select loginname from ibzuser where loginname=#{et.loginname}"
;
Map
<
String
,
Object
>
sqlParam
=
new
HashMap
<>();
sqlParam
.
put
(
"loginname"
,
loginname
);
List
<
JSONObject
>
select
=
iSysPSSystemService
.
select
(
sql
,
sqlParam
);
if
(
select
.
size
()
>
0
)
throw
new
BadRequestAlertException
(
"该用户名已被注册"
,
"UserRegisterResource"
,
""
);
IBZUSER
ibzuser
=
new
IBZUSER
();
if
(
StringUtils
.
isEmpty
(
avatar
))
{
// 通过code获取微信用户信息
JSONObject
returnObj
=
userRegisterService
.
requestWechatUserByCode
(
code
,
state
,
wechatAppId
,
wechatappsecret
);
if
(!
StringUtils
.
isEmpty
(
returnObj
)
&&
!
returnObj
.
containsKey
(
"errcode"
))
{
// 微信注册
String
uuid
=
UUID
.
randomUUID
().
toString
();
ibzuser
.
setPassword
(
password
);
ibzuser
.
setLoginname
(
loginname
);
ibzuser
.
setUserid
(
"wechat-"
+
uuid
);
ibzuser
.
setPersonname
(
returnObj
.
getString
(
"nickname"
));
ibzuser
.
setAvatar
(
returnObj
.
getString
(
"openid"
));
userRegisterService
.
toRegister
(
ibzuser
);
object
.
put
(
"ibzuser"
,
ibzuser
);
}
}
else
{
// 已经有微信用户信息直接注册
String
uuid
=
UUID
.
randomUUID
().
toString
();
ibzuser
.
setPassword
(
password
);
ibzuser
.
setLoginname
(
loginname
);
ibzuser
.
setUserid
(
"wechat-"
+
uuid
);
ibzuser
.
setPersonname
(
nickname
);
ibzuser
.
setAvatar
(
avatar
);
userRegisterService
.
toRegister
(
ibzuser
);
object
.
put
(
"ibzuser"
,
ibzuser
);
}
userDetailsService
.
resetByUsername
(
ibzuser
.
getLoginname
());
AuthenticationUser
user
=
userDetailsService
.
loadUserByLogin
(
ibzuser
.
getLoginname
(),
ibzuser
.
getPassword
());
final
String
token
=
jwtTokenUtil
.
generateToken
(
user
);
AuthenticationUser
user2
=
new
AuthenticationUser
();
CachedBeanCopier
.
copy
(
user
,
user2
);
user2
.
setAuthorities
(
null
);
user2
.
setPermissionList
(
null
);
object
.
put
(
"token"
,
token
);
object
.
put
(
"user"
,
user2
);
return
ResponseEntity
.
ok
().
body
(
object
);
}
/**
* 获取qq互联创建的网站应用appid
*/
@GetMapping
(
value
=
"/uaa/getQQAppId"
)
public
ResponseEntity
<
JSONObject
>
getTecentAppId
()
{
JSONObject
obj
=
new
JSONObject
();
String
appid
=
qqAppId
;
if
(!
StringUtils
.
isEmpty
(
appid
))
{
obj
.
put
(
"appid"
,
appid
);
}
return
ResponseEntity
.
ok
(
obj
);
}
/**
* 获取微信开放平台创建的网站应用appid
*/
@GetMapping
(
value
=
"/uaa/getWechatAppId"
)
public
ResponseEntity
<
JSONObject
>
getWechatAppId
()
{
JSONObject
obj
=
new
JSONObject
();
String
appid
=
wechatAppId
;
if
(!
StringUtils
.
isEmpty
(
appid
))
{
obj
.
put
(
"appid"
,
appid
);
}
return
ResponseEntity
.
ok
(
obj
);
}
/**
* 获取钉钉开放平台创建的网站应用appid
*/
@GetMapping
(
value
=
"/uaa/getDingtalkAppId"
)
public
ResponseEntity
<
JSONObject
>
getDingtalkAppId
()
{
JSONObject
obj
=
new
JSONObject
();
String
appid
=
dingTalkAppId
;
if
(!
StringUtils
.
isEmpty
(
appid
))
{
obj
.
put
(
"appid"
,
appid
);
}
return
ResponseEntity
.
ok
(
obj
);
}
/**
* 根据code查QQ用户
*
* @param param
* @return
*/
@PostMapping
(
value
=
"/uaa/queryQQUserByCode"
)
public
ResponseEntity
<
JSONObject
>
queryQQUserByCode
(
@RequestBody
JSONObject
param
)
{
JSONObject
object
=
new
JSONObject
();
// 空校验
String
code
=
param
.
getString
(
"code"
);
if
(
StringUtils
.
isEmpty
(
code
))
throw
new
BadRequestAlertException
(
"code为空"
,
"UserRegisterResource"
,
""
);
// 通过code获取qq用户信息
String
openid
=
""
;
JSONObject
returnObj
=
userRegisterService
.
requestQQUserByCode
(
code
,
qqRedirectUri
,
qqAppId
,
qqAppKey
);
if
(!
StringUtils
.
isEmpty
(
returnObj
)
&&
!
returnObj
.
containsKey
(
"errcode"
))
{
openid
=
returnObj
.
getString
(
"openid"
);
String
nickname
=
returnObj
.
getString
(
"nickname"
);
// 将用户信息存到缓存,供当前人后续请求使用
Avatar
=
openid
;
Nickname
=
nickname
;
// 返回用户信息
object
.
put
(
"avatar"
,
openid
);
object
.
put
(
"nickname"
,
nickname
);
}
//根据openid查用户
String
sql
=
"select * from ibzuser where avatar=#{et.avatar}"
;
Map
<
String
,
Object
>
sqlParam
=
new
HashMap
<>();
sqlParam
.
put
(
"avatar"
,
openid
);
List
<
JSONObject
>
select
=
iSysPSSystemService
.
select
(
sql
,
sqlParam
);
if
(
select
.
size
()
>
0
)
{
IBZUSER
ibzuser
=
select
.
get
(
0
).
toJavaObject
(
IBZUSER
.
class
);
object
.
put
(
"ibzuser"
,
ibzuser
);
userDetailsService
.
resetByUsername
(
ibzuser
.
getLoginname
());
AuthenticationUser
user
=
userDetailsService
.
loadUserByLogin
(
ibzuser
.
getLoginname
(),
ibzuser
.
getPassword
());
final
String
token
=
jwtTokenUtil
.
generateToken
(
user
);
AuthenticationUser
user2
=
new
AuthenticationUser
();
CachedBeanCopier
.
copy
(
user
,
user2
);
user2
.
setAuthorities
(
null
);
user2
.
setPermissionList
(
null
);
object
.
put
(
"token"
,
token
);
object
.
put
(
"user"
,
user2
);
}
return
ResponseEntity
.
ok
().
body
(
object
);
}
/**
* 根据code查微信用户
*
* @param param
* @return
*/
@PostMapping
(
value
=
"/uaa/queryWechatUserByCode"
)
public
ResponseEntity
<
JSONObject
>
queryWechatUserByCode
(
@RequestBody
JSONObject
param
)
{
JSONObject
object
=
new
JSONObject
();
// 空校验
String
code
=
param
.
getString
(
"code"
);
if
(
StringUtils
.
isEmpty
(
code
))
throw
new
BadRequestAlertException
(
"code为空"
,
"UserRegisterResource"
,
""
);
// 通过code获取微信用户信息
String
openid
=
""
;
JSONObject
returnObj
=
userRegisterService
.
requestWechatUserByCode
(
code
,
null
,
wechatAppId
,
wechatappsecret
);
if
(!
StringUtils
.
isEmpty
(
returnObj
)
&&
!
returnObj
.
containsKey
(
"errcode"
))
{
openid
=
returnObj
.
getString
(
"openid"
);
String
nickname
=
returnObj
.
getString
(
"nickname"
);
// 将用户信息存到缓存,供当前人后续请求使用
Avatar
=
openid
;
Nickname
=
nickname
;
// 返回用户信息
object
.
put
(
"avatar"
,
openid
);
object
.
put
(
"nickname"
,
nickname
);
}
//根据openid查用户
String
sql
=
"select * from ibzuser where avatar=#{et.avatar}"
;
Map
<
String
,
Object
>
sqlParam
=
new
HashMap
<>();
sqlParam
.
put
(
"avatar"
,
openid
);
List
<
JSONObject
>
select
=
iSysPSSystemService
.
select
(
sql
,
sqlParam
);
if
(
select
.
size
()
>
0
)
{
IBZUSER
ibzuser
=
select
.
get
(
0
).
toJavaObject
(
IBZUSER
.
class
);
object
.
put
(
"ibzuser"
,
ibzuser
);
userDetailsService
.
resetByUsername
(
ibzuser
.
getLoginname
());
AuthenticationUser
user
=
userDetailsService
.
loadUserByLogin
(
ibzuser
.
getLoginname
(),
ibzuser
.
getPassword
());
final
String
token
=
jwtTokenUtil
.
generateToken
(
user
);
AuthenticationUser
user2
=
new
AuthenticationUser
();
CachedBeanCopier
.
copy
(
user
,
user2
);
user2
.
setAuthorities
(
null
);
user2
.
setPermissionList
(
null
);
object
.
put
(
"token"
,
token
);
object
.
put
(
"user"
,
user2
);
}
return
ResponseEntity
.
ok
().
body
(
object
);
}
/**
* 根据code查钉钉用户
*
* @param param
* @return
*/
@PostMapping
(
value
=
"/uaa/queryDingtalkUserByCode"
)
public
ResponseEntity
<
JSONObject
>
queryDingtalkUserByCode
(
@RequestBody
JSONObject
param
)
{
JSONObject
object
=
new
JSONObject
();
// 空校验
String
code
=
param
.
getString
(
"code"
);
if
(
StringUtils
.
isEmpty
(
code
))
throw
new
BadRequestAlertException
(
"code为空"
,
"UserRegisterResource"
,
""
);
// 通过code获取钉钉用户信息
String
openid
=
""
;
long
currentTimeMillis
=
System
.
currentTimeMillis
();
JSONObject
returnObj
=
userRegisterService
.
requestDingtalkUserByCode
(
code
,
currentTimeMillis
,
dingTalkAppId
,
dingTalkAppSecret
);
if
(!
StringUtils
.
isEmpty
(
returnObj
)
&&
!
returnObj
.
containsKey
(
"errcode"
))
{
openid
=
returnObj
.
getString
(
"openid"
);
String
nickname
=
returnObj
.
getString
(
"nick"
);
// 将用户信息存到缓存,供当前人后续请求使用
Avatar
=
openid
;
Nickname
=
nickname
;
// 返回用户信息
object
.
put
(
"avatar"
,
openid
);
object
.
put
(
"nickname"
,
nickname
);
}
//根据openid查用户
String
sql
=
"select * from ibzuser where avatar=#{et.avatar}"
;
Map
<
String
,
Object
>
sqlParam
=
new
HashMap
<>();
sqlParam
.
put
(
"avatar"
,
openid
);
List
<
JSONObject
>
select
=
iSysPSSystemService
.
select
(
sql
,
sqlParam
);
if
(
select
.
size
()
>
0
)
{
IBZUSER
ibzuser
=
select
.
get
(
0
).
toJavaObject
(
IBZUSER
.
class
);
object
.
put
(
"ibzuser"
,
ibzuser
);
userDetailsService
.
resetByUsername
(
ibzuser
.
getLoginname
());
AuthenticationUser
user
=
userDetailsService
.
loadUserByLogin
(
ibzuser
.
getLoginname
(),
ibzuser
.
getPassword
());
final
String
token
=
jwtTokenUtil
.
generateToken
(
user
);
AuthenticationUser
user2
=
new
AuthenticationUser
();
CachedBeanCopier
.
copy
(
user
,
user2
);
user2
.
setAuthorities
(
null
);
user2
.
setPermissionList
(
null
);
object
.
put
(
"token"
,
token
);
object
.
put
(
"user"
,
user2
);
}
return
ResponseEntity
.
ok
().
body
(
object
);
}
/**
* 根据code获取微信用户信息
*
* @param param
* @return
*/
@PostMapping
(
value
=
"/uaa/getWechatUserInfoByCode"
)
public
ResponseEntity
<
JSONObject
>
getWechatUserInfoByCode
(
@RequestBody
JSONObject
param
)
{
JSONObject
object
=
new
JSONObject
();
// 空校验
String
code
=
param
.
getString
(
"code"
);
if
(
StringUtils
.
isEmpty
(
code
))
throw
new
BadRequestAlertException
(
"code为空"
,
"UserRegisterResource"
,
""
);
// 通过code获取微信用户信息
String
openid
=
Avatar
;
String
nickname
=
Nickname
;
object
.
put
(
"avatar"
,
openid
);
object
.
put
(
"nickname"
,
nickname
);
return
ResponseEntity
.
ok
().
body
(
object
);
}
/**
/**
* 根据openId查用户
* 根据openId查用户
...
@@ -94,7 +434,7 @@ public class UserRegisterResource {
...
@@ -94,7 +434,7 @@ public class UserRegisterResource {
// 空校验
// 空校验
String
openId
=
param
.
getString
(
"openId"
);
String
openId
=
param
.
getString
(
"openId"
);
if
(
StringUtils
.
isEmpty
(
openId
))
if
(
StringUtils
.
isEmpty
(
openId
))
throw
new
BadRequestAlertException
(
"openId为空"
,
"
queryUserByOpenId
"
,
""
);
throw
new
BadRequestAlertException
(
"openId为空"
,
"
UserRegisterResource
"
,
""
);
// 根据openid查用户
// 根据openid查用户
String
sql
=
"select * from ibzuser where avatar=#{et.avatar}"
;
String
sql
=
"select * from ibzuser where avatar=#{et.avatar}"
;
...
@@ -110,11 +450,9 @@ public class UserRegisterResource {
...
@@ -110,11 +450,9 @@ public class UserRegisterResource {
return
ResponseEntity
.
ok
().
body
(
object
);
return
ResponseEntity
.
ok
().
body
(
object
);
}
}
//这里的token要和微信测试号网页填写的token一样
public
static
final
String
TOKEN
=
"weixin"
;
/**
/**
* 响应微信发送的Token验证
* 响应微信
公众测试号
发送的Token验证
*
*
* @param signature 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数
* @param signature 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数
* @param timestamp 时间戳
* @param timestamp 时间戳
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录