Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
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
8timerv2
8timerapiv200
Commits
30ef854b
Commit
30ef854b
authored
May 20, 2022
by
陶湘宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信验证码5分钟保持一致
parent
1903fb68
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
src/main/java/cn/timer/api/controller/LoginController.java
+15
-11
src/main/java/cn/timer/api/controller/zpgl/ZpglWxgzptController.java
+1
-1
No files found.
src/main/java/cn/timer/api/controller/LoginController.java
View file @
30ef854b
...
@@ -222,12 +222,16 @@ public class LoginController {
...
@@ -222,12 +222,16 @@ public class LoginController {
// 6位随机数验证码
// 6位随机数验证码
try
{
try
{
Integer
code
=
(
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
);
if
(
phone
==
null
||
""
.
equals
(
phone
))
{
if
(
phone
==
null
||
""
.
equals
(
phone
))
{
phone
=
entRegisterDto
.
getUsername
();
phone
=
entRegisterDto
.
getUsername
();
entRegisterDto
.
setPhone
(
phone
);
entRegisterDto
.
setPhone
(
phone
);
}
}
Integer
code
=
Integer
.
parseInt
(
redisUtil
.
get
(
session
.
getId
()+
phone
)!=
null
?
redisUtil
.
get
(
session
.
getId
()+
phone
).
toString
():
"0"
);
if
(
code
==
0
)
{
code
=(
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
);
redisUtil
.
set
(
session
.
getId
()+
phone
,
code
,
60
*
5
);
}
List
<
Object
>
list
=
aliyunSMS
.
authCode
(
entRegisterDto
,
entRegisterDto
.
getTc
(),
code
);
List
<
Object
>
list
=
aliyunSMS
.
authCode
(
entRegisterDto
,
entRegisterDto
.
getTc
(),
code
);
Integer
useId
=
(
Integer
)
list
.
get
(
0
);
Integer
useId
=
(
Integer
)
list
.
get
(
0
);
JSONObject
j
=
(
JSONObject
)
list
.
get
(
1
);
JSONObject
j
=
(
JSONObject
)
list
.
get
(
1
);
...
@@ -257,10 +261,8 @@ public class LoginController {
...
@@ -257,10 +261,8 @@ public class LoginController {
String
message
=
j
.
getString
(
"Message"
);
String
message
=
j
.
getString
(
"Message"
);
if
(
"OK"
.
equals
(
message
))
{
if
(
"OK"
.
equals
(
message
))
{
redisUtil
.
set
(
phone
,
code
);
// redisTemplate.set(phone, code);
// redisTemplate.set(phone, code);
// redisTemplate.expire(phone, 60);
// redisTemplate.expire(phone, 60);
return
ResultUtil
.
data
(
"发送验证码成功"
);
return
ResultUtil
.
data
(
"发送验证码成功"
);
}
else
{
}
else
{
return
ResultUtil
.
error
(
"发送验证码失败"
);
return
ResultUtil
.
error
(
"发送验证码失败"
);
...
@@ -289,12 +291,15 @@ public class LoginController {
...
@@ -289,12 +291,15 @@ public class LoginController {
// 6位随机数验证码
// 6位随机数验证码
try
{
try
{
Integer
code
=
(
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
);
if
(
phone
==
null
||
""
.
equals
(
phone
))
{
if
(
phone
==
null
||
""
.
equals
(
phone
))
{
phone
=
entRegisterDto
.
getUsername
();
phone
=
entRegisterDto
.
getUsername
();
entRegisterDto
.
setPhone
(
phone
);
entRegisterDto
.
setPhone
(
phone
);
}
}
Integer
code
=
Integer
.
parseInt
(
redisUtil
.
get
(
session
.
getId
()+
phone
)!=
null
?
redisUtil
.
get
(
session
.
getId
()+
phone
).
toString
():
"0"
);
if
(
code
==
0
)
{
code
=(
int
)
((
Math
.
random
()
*
9
+
1
)
*
100000
);
redisUtil
.
set
(
session
.
getId
()+
phone
,
code
,
60
*
5
);
}
List
<
Object
>
list
=
aliyunSMS
.
authCode
(
entRegisterDto
,
entRegisterDto
.
getTc
(),
code
);
List
<
Object
>
list
=
aliyunSMS
.
authCode
(
entRegisterDto
,
entRegisterDto
.
getTc
(),
code
);
Integer
useId
=
(
Integer
)
list
.
get
(
0
);
Integer
useId
=
(
Integer
)
list
.
get
(
0
);
JSONObject
j
=
(
JSONObject
)
list
.
get
(
1
);
JSONObject
j
=
(
JSONObject
)
list
.
get
(
1
);
...
@@ -303,7 +308,6 @@ public class LoginController {
...
@@ -303,7 +308,6 @@ public class LoginController {
String
message
=
j
.
getString
(
"Message"
);
String
message
=
j
.
getString
(
"Message"
);
if
(
"OK"
.
equals
(
message
))
{
if
(
"OK"
.
equals
(
message
))
{
//session.setAttribute(phone, code);
//session.setAttribute(phone, code);
redisUtil
.
set
(
phone
,
code
,
60
*
5
);
return
ResultUtil
.
data
(
"发送验证码成功"
);
return
ResultUtil
.
data
(
"发送验证码成功"
);
}
else
{
}
else
{
return
ResultUtil
.
error
(
"发送验证码失败"
);
return
ResultUtil
.
error
(
"发送验证码失败"
);
...
@@ -328,7 +332,7 @@ public class LoginController {
...
@@ -328,7 +332,7 @@ public class LoginController {
String
code
=
entRegisterDto
.
getCode
().
toString
();
String
code
=
entRegisterDto
.
getCode
().
toString
();
String
codeRedis
=
redisUtil
.
get
(
phone
)
!=
null
?
redisUtil
.
get
(
phone
).
toString
()
:
""
;
String
codeRedis
=
redisUtil
.
get
(
session
.
getId
()+
phone
)
!=
null
?
redisUtil
.
get
(
session
.
getId
()+
phone
).
toString
()
:
""
;
if
(
authentication_code
!=
null
&&
!(
""
).
equals
(
authentication_code
))
{
if
(
authentication_code
!=
null
&&
!(
""
).
equals
(
authentication_code
))
{
if
(
authentication_code
.
equals
(
code
))
{
if
(
authentication_code
.
equals
(
code
))
{
...
@@ -368,7 +372,7 @@ public class LoginController {
...
@@ -368,7 +372,7 @@ public class LoginController {
}
else
{
}
else
{
if
(
authentication_code
==
null
||
(
""
).
equals
(
authentication_code
)
||
!
authentication_code
.
equals
(
code
))
{
if
(
authentication_code
==
null
||
(
""
).
equals
(
authentication_code
)
||
!
authentication_code
.
equals
(
code
))
{
String
codeRedis
=
redisUtil
.
get
(
phone
)
!=
null
?
redisUtil
.
get
(
phone
).
toString
()
:
""
;
String
codeRedis
=
redisUtil
.
get
(
session
.
getId
()+
phone
)
!=
null
?
redisUtil
.
get
(
session
.
getId
()+
phone
).
toString
()
:
""
;
if
(!
code
.
equals
(
codeRedis
))
{
if
(!
code
.
equals
(
codeRedis
))
{
return
ResultUtil
.
error
(
"短信验证码错误"
);
return
ResultUtil
.
error
(
"短信验证码错误"
);
}
}
...
@@ -403,7 +407,7 @@ public class LoginController {
...
@@ -403,7 +407,7 @@ public class LoginController {
String
code
=
entRegisterDto
.
getCode
();
String
code
=
entRegisterDto
.
getCode
();
if
(
entRegisterDto
.
getPwUpdateType
()
!=
2
)
{
if
(
entRegisterDto
.
getPwUpdateType
()
!=
2
)
{
String
codeRedis
=
redisUtil
.
get
(
phone
)!=
null
?
redisUtil
.
get
(
phone
).
toString
()
:
""
;
String
codeRedis
=
redisUtil
.
get
(
session
.
getId
()+
phone
)!=
null
?
redisUtil
.
get
(
session
.
getId
()+
phone
).
toString
()
:
""
;
if
(
code
==
null
)
{
if
(
code
==
null
)
{
return
ResultUtil
.
error
(
"请填写验证码"
);
return
ResultUtil
.
error
(
"请填写验证码"
);
}
}
...
@@ -469,7 +473,7 @@ public class LoginController {
...
@@ -469,7 +473,7 @@ public class LoginController {
String
phone
=
entRegisterDto
.
getPhone
();
String
phone
=
entRegisterDto
.
getPhone
();
String
code
=
entRegisterDto
.
getCode
();
String
code
=
entRegisterDto
.
getCode
();
// String codeRedis = redisTemplate.get(phone).toString();
// String codeRedis = redisTemplate.get(phone).toString();
String
codeRedis
=
redisUtil
.
get
(
phone
)
!=
null
?
redisUtil
.
get
(
phone
).
toString
()
:
""
;
String
codeRedis
=
redisUtil
.
get
(
session
.
getId
()+
phone
)
!=
null
?
redisUtil
.
get
(
session
.
getId
()+
phone
).
toString
()
:
""
;
if
(
authentication_code
!=
null
&&
!(
""
).
equals
(
authentication_code
))
{
if
(
authentication_code
!=
null
&&
!(
""
).
equals
(
authentication_code
))
{
if
(
authentication_code
.
equals
(
code
))
{
if
(
authentication_code
.
equals
(
code
))
{
...
@@ -745,7 +749,7 @@ public class LoginController {
...
@@ -745,7 +749,7 @@ public class LoginController {
return
ResultUtil
.
error
(
"请输入验证码"
);
return
ResultUtil
.
error
(
"请输入验证码"
);
}
}
String
phone
=
entRegisterDto
.
getPhone
();
String
phone
=
entRegisterDto
.
getPhone
();
String
codeRedis
=
redisUtil
.
get
(
phone
)!=
null
?
redisUtil
.
get
(
phone
).
toString
()
:
""
;
String
codeRedis
=
redisUtil
.
get
(
session
.
getId
()+
phone
)!=
null
?
redisUtil
.
get
(
session
.
getId
()+
phone
).
toString
()
:
""
;
if
(
authentication_code
!=
null
&&
!(
""
).
equals
(
authentication_code
))
{
if
(
authentication_code
!=
null
&&
!(
""
).
equals
(
authentication_code
))
{
if
(
authentication_code
.
equals
(
code
))
{
if
(
authentication_code
.
equals
(
code
))
{
...
...
src/main/java/cn/timer/api/controller/zpgl/ZpglWxgzptController.java
View file @
30ef854b
...
@@ -184,7 +184,7 @@ public class ZpglWxgzptController {
...
@@ -184,7 +184,7 @@ public class ZpglWxgzptController {
return
ResultUtil
.
error
(
"请输入验证码"
);
return
ResultUtil
.
error
(
"请输入验证码"
);
}
}
//String codeRedis = session.getAttribute(phone) != null ? session.getAttribute(phone).toString() : "";
//String codeRedis = session.getAttribute(phone) != null ? session.getAttribute(phone).toString() : "";
String
codeRedis
=
redisUtil
.
get
(
phone
)
!=
null
?
redisUtil
.
get
(
phone
).
toString
()
:
null
;
String
codeRedis
=
redisUtil
.
get
(
session
.
getId
()+
phone
)
!=
null
?
redisUtil
.
get
(
session
.
getId
()+
phone
).
toString
()
:
null
;
if
(
authentication_code
!=
null
&&
!(
""
).
equals
(
authentication_code
))
{
if
(
authentication_code
!=
null
&&
!(
""
).
equals
(
authentication_code
))
{
if
(
authentication_code
.
equals
(
code
))
{
if
(
authentication_code
.
equals
(
code
))
{
return
loginhan
(
phone
,
openid
);
return
loginhan
(
phone
,
openid
);
...
...
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