Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3346a624
authored
Nov 18, 2024
by
lujunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信次数
parent
21e8eb54
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
app/Admin/Controllers/AuthController.php
+10
-0
No files found.
app/Admin/Controllers/AuthController.php
View file @
3346a624
...
@@ -113,11 +113,21 @@ public function getLoginSmsCode(Request $request)
...
@@ -113,11 +113,21 @@ public function getLoginSmsCode(Request $request)
return
response
()
->
json
([
'error'
=>
'该药店手机号未注册,请联系管理员~'
]);
return
response
()
->
json
([
'error'
=>
'该药店手机号未注册,请联系管理员~'
]);
}
}
// 检查当天发送次数
$today
=
date
(
'Y-m-d'
);
$smsCountKey
=
"sms_count_
{
$phone
}
_
{
$today
}
"
;
$smsCount
=
cache
()
->
get
(
$smsCountKey
,
0
);
if
(
$smsCount
>=
10
)
{
return
response
()
->
json
([
'error'
=>
'今天该手机号已达到发送次数上限'
]);
}
// 生成短信验证码
// 生成短信验证码
$verificationCode
=
rand
(
100000
,
999999
);
// 生成6位随机验证码
$verificationCode
=
rand
(
100000
,
999999
);
// 生成6位随机验证码
// 存储验证码和有效期(10分钟)
// 存储验证码和有效期(10分钟)
cache
()
->
put
(
"sms_verification_code_
{
$phone
}
"
,
$verificationCode
,
600
);
// 600秒 = 10分钟
cache
()
->
put
(
"sms_verification_code_
{
$phone
}
"
,
$verificationCode
,
600
);
// 600秒 = 10分钟
// 设置当天发送次数的过期时间为当天结束
cache
()
->
put
(
$smsCountKey
,
$smsCount
+
1
,
strtotime
(
'tomorrow'
)
-
time
());
// 设置为明天0点过期
$templateName
=
'verification_code'
;
$templateName
=
'verification_code'
;
$templateData
=
[
'code'
=>
$verificationCode
];
$templateData
=
[
'code'
=>
$verificationCode
];
...
...
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