Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
civil-bigdata
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
civil
civil-bigdata
Commits
a23071f7
Commit
a23071f7
authored
Dec 22, 2021
by
韦华德
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
民政单点登录:增加手机验证码,注册去掉邮箱
parent
45e80ae8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
+23
-12
sys-server/src/main/java/com/zq/system/modules/system/rest/SsoController.java
+2
-1
sys-server/src/main/java/com/zq/system/modules/system/service/SsoService.java
+21
-11
No files found.
sys-server/src/main/java/com/zq/system/modules/system/rest/SsoController.java
View file @
a23071f7
...
...
@@ -69,7 +69,8 @@ public class SsoController {
@ApiOperation
(
"获取手机验证码"
)
@AnonymousGetMapping
(
value
=
"/getPhoneVerificationCode/{phoneNumber}"
)
public
ResultVo
getPhoneVerificationCode
(
@PathVariable
(
"phoneNumber"
)
String
phoneNumber
)
{
return
ResultVo
.
success
(
ssoService
.
getPhoneVerificationCode
(
phoneNumber
));
ssoService
.
getPhoneVerificationCode
(
phoneNumber
);
return
ResultVo
.
success
();
}
...
...
sys-server/src/main/java/com/zq/system/modules/system/service/SsoService.java
View file @
a23071f7
package
com
.
zq
.
system
.
modules
.
system
.
service
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.http.HttpRequest
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.json.JSONObject
;
...
...
@@ -34,7 +35,7 @@ import com.zq.system.utils.MobileSmsUtils;
import
com.zq.system.utils.RsaUtils
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang
3
.StringUtils
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.core.Authentication
;
...
...
@@ -79,9 +80,7 @@ public class SsoService {
}
AssertUtils
.
hasText
(
passwd
,
"密码解密失败"
);
String
phoneVerificationCode
=
redisUtils
.
getStr
(
vo
.
getUuId
());
// AssertUtils.hasText(phoneVerificationCode,"验证码已过期");
// AssertUtils.isTrue(vo.getPhoneVerificationCode().equals(phoneVerificationCode),"验证码错误");
verificationCode
(
vo
.
getPhone
(),
vo
.
getPhoneVerificationCode
());
User
resources
=
new
User
();
resources
.
setPassword
(
passwordEncoder
.
encode
(
passwd
));
...
...
@@ -245,12 +244,23 @@ public class SsoService {
return
data
;
}
public
String
getPhoneVerificationCode
(
String
phoneNumber
)
{
String
code
=
String
.
valueOf
((
int
)((
Math
.
random
()*
9
+
1
)*
100000
));
MobileSmsUtils
.
sendMsg
(
phoneNumber
,
"【民政统一登录平台】验证码:"
+
code
+
"(有效期为3分钟),请勿泄露给他人,如非本人操作,请忽略此信息。"
);
String
uuid
=
properties
.
getCodeKey
()
+
IdUtil
.
simpleUUID
();
//3分钟
redisUtils
.
setStr
(
uuid
,
code
,
180000
);
return
uuid
;
public
void
getPhoneVerificationCode
(
String
phone
)
{
String
code
=
RandomUtil
.
randomNumbers
(
6
);
String
content
=
"您的验证码为:"
+
code
+
"(5分钟内有效)。为了保障信息安全,如非本人操作请忽略本短信。"
;
boolean
sendMsg
=
MobileSmsUtils
.
sendMsg
(
phone
,
content
);
log
.
info
(
">> phone: {}, sendCode: {}, success: {}"
,
phone
,
code
,
sendMsg
);
redisUtils
.
setStr
(
CacheKeys
.
authCodeKey
(
phone
),
code
,
5
);
}
/**
* 判断验证码
*
* @param phone
* @param code
*/
public
void
verificationCode
(
String
phone
,
String
code
)
{
String
cacheCode
=
redisUtils
.
getStr
(
CacheKeys
.
authCodeKey
(
phone
));
AssertUtils
.
isTrue
(
StringUtils
.
isNotBlank
(
cacheCode
)
&&
cacheCode
.
equalsIgnoreCase
(
code
),
"验证码错误"
);
redisUtils
.
deleteStr
(
CacheKeys
.
authCodeKey
(
phone
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment