Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
7ff24fb9
提交
7ff24fb9
编写于
8月 03, 2020
作者:
laizhilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
第三方注册时创建用户授权信息
上级
0222cbcc
变更
10
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
128 行增加
和
153 行删除
+128
-153
dingdingLoginRedirect.vue
app_web/src/components/login/dingdingLoginRedirect.vue
+2
-0
login.vue
app_web/src/components/login/login.vue
+2
-2
qqLoginRedirect.vue
app_web/src/components/login/qqLoginRedirect.vue
+2
-54
weixinLoginRedirect.vue
app_web/src/components/login/weixinLoginRedirect.vue
+2
-0
UserDingtalkRegisterService.java
...e/uaa/extensions/service/UserDingtalkRegisterService.java
+17
-2
UserQQRegisterService.java
...ab/core/uaa/extensions/service/UserQQRegisterService.java
+16
-1
UserWechatRegisterService.java
...ore/uaa/extensions/service/UserWechatRegisterService.java
+16
-1
UserDingtalkRegisterResource.java
...lab/api/rest/extensions/UserDingtalkRegisterResource.java
+24
-23
UserQQRegisterResource.java
...n/ibizlab/api/rest/extensions/UserQQRegisterResource.java
+23
-35
UserWechatRegisterResource.java
...izlab/api/rest/extensions/UserWechatRegisterResource.java
+24
-35
未找到文件。
app_web/src/components/login/dingdingLoginRedirect.vue
浏览文件 @
7ff24fb9
...
...
@@ -266,6 +266,8 @@
closable
:
true
});
}
// 返回登录页
this
.
goLogin
();
});
}
...
...
app_web/src/components/login/login.vue
浏览文件 @
7ff24fb9
...
...
@@ -49,7 +49,7 @@
<span
class=
"form_tipinfo"
>
其他登录方式
</span>
</div>
<div
style=
"text-align: center"
>
<div
class=
"sign-btn"
@
click=
"
tencentHandleClick('tencent
')"
>
<div
class=
"sign-btn"
@
click=
"
qqHandleClick('qq
')"
>
<img
src=
"/assets/img/QQ.svg"
class=
"qq-svg-container"
draggable=
"false"
>
</div>
<div
class=
"sign-btn"
@
click=
"wechatHandleClick('wechat')"
>
...
...
@@ -258,7 +258,7 @@
* qq授权登录
* @param thirdpart
*/
public
tencent
HandleClick
(
thirdpart
:
any
)
{
public
qq
HandleClick
(
thirdpart
:
any
)
{
// 截取地址,拼接需要部分组成新地址
const
baseUrl
=
this
.
getNeedLocation
();
...
...
app_web/src/components/login/qqLoginRedirect.vue
浏览文件 @
7ff24fb9
...
...
@@ -272,63 +272,11 @@
closable
:
true
});
}
// 返回登录页
this
.
goLogin
();
});
}
/**
* 自动登录倒计时
*/
public
countDown
(
totalTime
:
any
):
void
{
if
(
!
this
.
canClick
)
return
;
this
.
canClick
=
false
;
this
.
BtnContent
=
totalTime
+
's后自动登录'
;
// 设置定时器
let
clock
=
window
.
setInterval
(()
=>
{
// 秒数-1
totalTime
--
;
this
.
BtnContent
=
totalTime
+
's后自动登录'
;
if
(
totalTime
<
0
)
{
// 清除定时器
window
.
clearInterval
(
clock
);
// 登录请求
const
loginname
:
any
=
this
.
form
.
loginname
;
const
password
:
any
=
this
.
form
.
password
;
const
post
:
Promise
<
any
>
=
this
.
$http
.
post
(
'v7/login'
,
this
.
form
,
true
);
post
.
then
((
response
:
any
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
data
=
response
.
data
;
if
(
data
&&
data
.
token
)
{
localStorage
.
setItem
(
'token'
,
data
.
token
);
}
if
(
data
&&
data
.
user
)
{
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
data
.
user
));
}
// 设置cookie,保存账号密码7天
this
.
setCookie
(
loginname
,
password
,
7
);
// 跳转首页
const
url
:
any
=
this
.
$route
.
query
.
redirect
?
this
.
$route
.
query
.
redirect
:
'*'
;
this
.
$router
.
push
({
path
:
url
});
}
}).
catch
((
error
:
any
)
=>
{
const
data
=
error
.
data
;
if
(
data
&&
data
.
detail
)
{
this
.
$Message
.
error
({
content
:
"登录失败,"
+
data
.
detail
,
duration
:
3
,
closable
:
true
});
}
else
{
this
.
$Message
.
error
({
content
:
"登录失败"
,
duration
:
3
,
closable
:
true
});
}
});
}
},
1000
)
}
/**
...
...
app_web/src/components/login/weixinLoginRedirect.vue
浏览文件 @
7ff24fb9
...
...
@@ -268,6 +268,8 @@
closable
:
true
});
}
// 返回登录页
this
.
goLogin
();
});
}
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/UserDingtalkRegisterService.java
浏览文件 @
7ff24fb9
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
service
;
import
cn.ibizlab.core.uaa.domain.SysUserAuth
;
import
cn.ibizlab.core.uaa.service.ISysUserAuthService
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.service.IBZUSERService
;
...
...
@@ -33,7 +35,8 @@ public class UserDingtalkRegisterService {
@Autowired
private
IBZUSERService
ibzuserService
;
@Autowired
private
ISysUserAuthService
sysUserAuthService
;
/**
* 注册
...
...
@@ -48,6 +51,18 @@ public class UserDingtalkRegisterService {
}
}
/**
* 创建钉钉用户授权信息
* @param userAuth
*/
public
void
toCreateUserAuth
(
SysUserAuth
userAuth
)
{
// 创建用户授权信息
boolean
flag
=
sysUserAuthService
.
create
(
userAuth
);
if
(!
flag
)
{
throw
new
BadRequestAlertException
(
"保存用户授权信息失败"
,
"UserDingtalkRegisterService"
,
""
);
}
}
/**
* 钉钉服务端通过临时授权码code获取授权用户的个人信息
...
...
@@ -72,7 +87,7 @@ public class UserDingtalkRegisterService {
// 通过临时授权码Code获取用户信息,临时授权码只能使用一次
String
url
=
"https://oapi.dingtalk.com/sns/getuserinfo_bycode?accessKey="
+
dingTalkAppId
+
"×tamp="
+
String
.
valueOf
(
currentTimeMillis
)
+
"×tamp="
+
currentTimeMillis
+
"&signature="
+
urlEncodeSignature
;
// 创建httpclient对象
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/UserQQRegisterService.java
浏览文件 @
7ff24fb9
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
service
;
import
cn.ibizlab.core.uaa.domain.SysUserAuth
;
import
cn.ibizlab.core.uaa.service.ISysUserAuthService
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.HttpUtils
;
...
...
@@ -21,7 +23,8 @@ public class UserQQRegisterService {
@Autowired
private
IBZUSERService
ibzuserService
;
@Autowired
private
ISysUserAuthService
sysUserAuthService
;
/**
* 注册
...
...
@@ -36,6 +39,17 @@ public class UserQQRegisterService {
}
}
/**
* 创建QQ用户授权信息
* @param ibzuser
*/
public
void
toCreateUserAuth
(
SysUserAuth
ibzuser
)
{
// 创建用户授权信息
boolean
flag
=
sysUserAuthService
.
create
(
ibzuser
);
if
(!
flag
)
{
throw
new
BadRequestAlertException
(
"保存用户授权信息失败"
,
"UserQQRegisterService"
,
""
);
}
}
/**
* 通过code获取QQ用户信息
...
...
@@ -112,4 +126,5 @@ public class UserQQRegisterService {
}
}
\ No newline at end of file
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/extensions/service/UserWechatRegisterService.java
浏览文件 @
7ff24fb9
package
cn
.
ibizlab
.
core
.
uaa
.
extensions
.
service
;
import
cn.ibizlab.core.uaa.domain.SysUserAuth
;
import
cn.ibizlab.core.uaa.service.ISysUserAuthService
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.HttpUtils
;
...
...
@@ -21,7 +23,8 @@ public class UserWechatRegisterService {
@Autowired
private
IBZUSERService
ibzuserService
;
@Autowired
private
ISysUserAuthService
sysUserAuthService
;
/**
* 注册
...
...
@@ -37,6 +40,18 @@ public class UserWechatRegisterService {
}
/**
* 创建微信用户授权信息
* @param userAuth
*/
public
void
toCreateUserAuth
(
SysUserAuth
userAuth
)
{
// 创建用户授权信息
boolean
flag
=
sysUserAuthService
.
create
(
userAuth
);
if
(!
flag
)
{
throw
new
BadRequestAlertException
(
"保存用户授权信息失败"
,
"UserWechatRegisterService"
,
""
);
}
}
/**
* 通过code获取微信用户信息
*
...
...
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/UserDingtalkRegisterResource.java
浏览文件 @
7ff24fb9
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.core.uaa.domain.SysUserAuth
;
import
cn.ibizlab.core.uaa.extensions.service.UserDingtalkRegisterService
;
import
cn.ibizlab.core.uaa.service.ISysUserAuthService
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
...
...
@@ -32,6 +34,8 @@ public class UserDingtalkRegisterResource {
@Autowired
private
IBZUSERService
ibzuserService
;
@Autowired
private
ISysUserAuthService
sysUserAuthService
;
@Autowired
private
AuthTokenUtil
jwtTokenUtil
;
@Autowired
@Qualifier
(
"UAAUserService"
)
...
...
@@ -83,11 +87,12 @@ public class UserDingtalkRegisterResource {
object
.
put
(
"nickname"
,
nickname
);
}
//
根据openid查用户
List
<
IBZUSER
>
ibzusers
=
ibzuserService
.
list
(
Wrappers
.<
IBZUSER
>
query
().
eq
(
"avata
r"
,
openid
));
//
根据openid查用户授权信息
List
<
SysUserAuth
>
sysUserAuths
=
sysUserAuthService
.
list
(
Wrappers
.<
SysUserAuth
>
query
().
eq
(
"identifie
r"
,
openid
));
// 该钉钉用户注册过账号,登录系统
if
(
ibzusers
.
size
()
>
0
)
{
IBZUSER
ibzuser
=
ibzusers
.
get
(
0
);
if
(
sysUserAuths
.
size
()>
0
)
{
SysUserAuth
userauth
=
sysUserAuths
.
get
(
0
);
IBZUSER
ibzuser
=
ibzuserService
.
getById
(
userauth
.
getUserid
());
object
.
put
(
"ibzuser"
,
ibzuser
);
// 生成登录token信息
...
...
@@ -129,26 +134,22 @@ public class UserDingtalkRegisterResource {
if
(
StringUtils
.
isEmpty
(
nickname
))
throw
new
BadRequestAlertException
(
"钉钉信息nickname为空"
,
"UserDingtalkRegisterResource"
,
""
);
// 检查用户名是否已被注册
List
<
IBZUSER
>
ibzusers
=
ibzuserService
.
list
(
Wrappers
.<
IBZUSER
>
query
().
eq
(
"loginname"
,
loginname
));
if
(
ibzusers
.
size
()
>
0
)
throw
new
BadRequestAlertException
(
"该用户名已被注册"
,
"UserDingtalkRegisterResource"
,
""
);
// 钉钉用户注册
IBZUSER
ibzuser
=
new
IBZUSER
();
if
(
StringUtils
.
isEmpty
(
openid
))
{
// 钉钉授权code已失效,重新授权
throw
new
BadRequestAlertException
(
"钉钉授权已失效,请重新授权"
,
"UserDingtalkRegisterResource"
,
""
);
}
else
{
// 已经有钉钉用户信息直接注册
String
uuid
=
UUID
.
randomUUID
().
toString
();
ibzuser
.
setPassword
(
password
);
ibzuser
.
setLoginname
(
loginname
);
ibzuser
.
setUserid
(
"dingtalk-"
+
uuid
);
ibzuser
.
setPersonname
(
nickname
);
ibzuser
.
setNickname
(
nickname
);
ibzuser
.
setAvatar
(
openid
);
userDingtalkRegisterService
.
toRegister
(
ibzuser
);
}
// 创建钉钉用户授权信息
SysUserAuth
userAuth
=
new
SysUserAuth
();
userAuth
.
setUserid
(
ibzuser
.
getUserid
());
userAuth
.
setIdentifier
(
openid
);
userAuth
.
setIdentityType
(
"dingtalk"
);
userDingtalkRegisterService
.
toCreateUserAuth
(
userAuth
);
// 注册成功,登录系统
if
(!
StringUtils
.
isEmpty
(
ibzuser
))
{
...
...
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/UserQQRegisterResource.java
浏览文件 @
7ff24fb9
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.core.uaa.domain.SysUserAuth
;
import
cn.ibizlab.core.uaa.extensions.service.UserQQRegisterService
;
import
cn.ibizlab.core.uaa.service.ISysUserAuthService
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
...
...
@@ -32,6 +34,8 @@ public class UserQQRegisterResource {
@Autowired
private
IBZUSERService
ibzuserService
;
@Autowired
private
ISysUserAuthService
sysUserAuthService
;
@Autowired
private
AuthTokenUtil
jwtTokenUtil
;
@Autowired
@Qualifier
(
"UAAUserService"
)
...
...
@@ -84,11 +88,12 @@ public class UserQQRegisterResource {
object
.
put
(
"nickname"
,
nickname
);
}
//
根据openid查用户
List
<
IBZUSER
>
ibzusers
=
ibzuserService
.
list
(
Wrappers
.<
IBZUSER
>
query
().
eq
(
"avata
r"
,
openid
));
//
根据openid查用户授权信息
List
<
SysUserAuth
>
sysUserAuths
=
sysUserAuthService
.
list
(
Wrappers
.<
SysUserAuth
>
query
().
eq
(
"identifie
r"
,
openid
));
// 该QQ用户注册过账号,登录系统
if
(
ibzusers
.
size
()
>
0
)
{
IBZUSER
ibzuser
=
ibzusers
.
get
(
0
);
if
(
sysUserAuths
.
size
()>
0
)
{
SysUserAuth
userauth
=
sysUserAuths
.
get
(
0
);
IBZUSER
ibzuser
=
ibzuserService
.
getById
(
userauth
.
getUserid
());
object
.
put
(
"ibzuser"
,
ibzuser
);
// 生成登录token信息
...
...
@@ -142,38 +147,21 @@ public class UserQQRegisterResource {
if
(
ibzusers
.
size
()
>
0
)
throw
new
BadRequestAlertException
(
"该用户名已被注册"
,
"UserQQRegisterResource"
,
""
);
// QQ用户注册
IBZUSER
ibzuser
=
new
IBZUSER
();
if
(
StringUtils
.
isEmpty
(
openid
))
{
// 通过code获取微信用户信息
JSONObject
returnObj
=
userQQRegisterService
.
requestQQUserByCode
(
code
,
qqRedirectUri
,
qqAppId
,
qqAppKey
);
if
(!
StringUtils
.
isEmpty
(
returnObj
))
{
if
(
returnObj
.
containsKey
(
"openid"
))
{
// 微信注册
String
uuid
=
UUID
.
randomUUID
().
toString
();
ibzuser
.
setPassword
(
password
);
ibzuser
.
setLoginname
(
loginname
);
ibzuser
.
setUserid
(
"tencent-"
+
uuid
);
ibzuser
.
setPersonname
(
returnObj
.
getString
(
"nickname"
));
ibzuser
.
setNickname
(
returnObj
.
getString
(
"nickname"
));
ibzuser
.
setAvatar
(
returnObj
.
getString
(
"openid"
));
userQQRegisterService
.
toRegister
(
ibzuser
);
}
else
{
throw
new
BadRequestAlertException
(
"获取QQ授权用户相关信息失败!"
,
"UserQQRegisterResource"
,
""
);
}
}
else
{
throw
new
BadRequestAlertException
(
"获取QQ授权用户相关信息失败!"
,
"UserQQRegisterResource"
,
""
);
}
}
else
{
// 已经有微信用户信息直接注册
String
uuid
=
UUID
.
randomUUID
().
toString
();
ibzuser
.
setPassword
(
password
);
ibzuser
.
setLoginname
(
loginname
);
ibzuser
.
setUserid
(
"tencent-"
+
uuid
);
ibzuser
.
setUserid
(
"qq-"
+
uuid
);
ibzuser
.
setPersonname
(
nickname
);
ibzuser
.
setNickname
(
nickname
);
ibzuser
.
setAvatar
(
openid
);
userQQRegisterService
.
toRegister
(
ibzuser
);
}
// 创建QQ用户授权信息
SysUserAuth
userAuth
=
new
SysUserAuth
();
userAuth
.
setUserid
(
ibzuser
.
getUserid
());
userAuth
.
setIdentifier
(
openid
);
userAuth
.
setIdentityType
(
"qq"
);
userQQRegisterService
.
toCreateUserAuth
(
userAuth
);
// 注册成功,登录系统
if
(!
StringUtils
.
isEmpty
(
ibzuser
))
{
...
...
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/UserWechatRegisterResource.java
浏览文件 @
7ff24fb9
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.core.uaa.domain.SysUserAuth
;
import
cn.ibizlab.core.uaa.extensions.service.UserWechatRegisterService
;
import
cn.ibizlab.core.uaa.service.ISysUserAuthService
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
...
...
@@ -32,6 +34,8 @@ public class UserWechatRegisterResource {
@Autowired
private
IBZUSERService
ibzuserService
;
@Autowired
private
ISysUserAuthService
sysUserAuthService
;
@Autowired
private
AuthTokenUtil
jwtTokenUtil
;
@Autowired
@Qualifier
(
"UAAUserService"
)
...
...
@@ -83,11 +87,12 @@ public class UserWechatRegisterResource {
object
.
put
(
"nickname"
,
nickname
);
}
//
根据openid查用户
List
<
IBZUSER
>
ibzusers
=
ibzuserService
.
list
(
Wrappers
.<
IBZUSER
>
query
().
eq
(
"avata
r"
,
openid
));
//
根据openid查用户授权信息
List
<
SysUserAuth
>
sysUserAuths
=
sysUserAuthService
.
list
(
Wrappers
.<
SysUserAuth
>
query
().
eq
(
"identifie
r"
,
openid
));
// 该微信用户注册过账号,登录系统
if
(
ibzusers
.
size
()
>
0
)
{
IBZUSER
ibzuser
=
ibzusers
.
get
(
0
);
if
(
sysUserAuths
.
size
()>
0
)
{
SysUserAuth
userauth
=
sysUserAuths
.
get
(
0
);
IBZUSER
ibzuser
=
ibzuserService
.
getById
(
userauth
.
getUserid
());
object
.
put
(
"ibzuser"
,
ibzuser
);
// 生成登录token信息
...
...
@@ -102,6 +107,7 @@ public class UserWechatRegisterResource {
object
.
put
(
"user"
,
user2
);
}
return
ResponseEntity
.
ok
().
body
(
object
);
}
...
...
@@ -141,38 +147,21 @@ public class UserWechatRegisterResource {
if
(
ibzusers
.
size
()
>
0
)
throw
new
BadRequestAlertException
(
"该用户名已被注册"
,
"UserWechatRegisterResource"
,
""
);
// 微信用户注册
IBZUSER
ibzuser
=
new
IBZUSER
();
if
(
StringUtils
.
isEmpty
(
openid
))
{
// 通过code获取微信用户信息
JSONObject
returnObj
=
userWechatRegisterService
.
requestWechatUserByCode
(
code
,
null
,
WechatAppid
,
WechatAppsecret
);
if
(!
StringUtils
.
isEmpty
(
returnObj
))
{
if
(
returnObj
.
containsKey
(
"openid"
))
{
// 微信注册
String
uuid
=
UUID
.
randomUUID
().
toString
();
ibzuser
.
setPassword
(
password
);
ibzuser
.
setLoginname
(
loginname
);
ibzuser
.
setUserid
(
"wechat-"
+
uuid
);
ibzuser
.
setPersonname
(
returnObj
.
getString
(
"nickname"
));
ibzuser
.
setNickname
(
returnObj
.
getString
(
"nickname"
));
ibzuser
.
setAvatar
(
returnObj
.
getString
(
"openid"
));
userWechatRegisterService
.
toRegister
(
ibzuser
);
}
else
{
throw
new
BadRequestAlertException
(
"获取微信授权用户相关信息失败!"
,
"UserWechatRegisterResource"
,
""
);
}
}
else
{
throw
new
BadRequestAlertException
(
"获取微信授权用户相关信息失败!"
,
"UserWechatRegisterResource"
,
""
);
}
}
else
{
// 已经有微信用户信息直接注册
String
uuid
=
UUID
.
randomUUID
().
toString
();
ibzuser
.
setPassword
(
password
);
ibzuser
.
setLoginname
(
loginname
);
ibzuser
.
setUserid
(
"wechat-"
+
uuid
);
ibzuser
.
setPersonname
(
nickname
);
ibzuser
.
setNickname
(
nickname
);
ibzuser
.
setAvatar
(
openid
);
userWechatRegisterService
.
toRegister
(
ibzuser
);
}
// 创建微信用户授权信息
SysUserAuth
userAuth
=
new
SysUserAuth
();
userAuth
.
setUserid
(
ibzuser
.
getUserid
());
userAuth
.
setIdentifier
(
openid
);
userAuth
.
setIdentityType
(
"wechat"
);
userWechatRegisterService
.
toCreateUserAuth
(
userAuth
);
// 注册成功,登录系统
if
(!
StringUtils
.
isEmpty
(
ibzuser
))
{
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录