Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
方斌
51business
Commits
bf62b6fa
Commit
bf62b6fa
authored
Apr 18, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix login
parent
5c22fbdd
Pipeline
#21862
passed with stage
in 12 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
user.js
app/service/course/v5/user.js
+12
-7
No files found.
app/service/course/v5/user.js
View file @
bf62b6fa
...
...
@@ -14,15 +14,15 @@ class UserService extends Service {
const
APP_ID
=
'1C1wN39F4s61w62'
;
const
APP_KEY
=
'6643BBA3-2663-4A69-BA4E-2711D6B0AED5'
;
if
(
!
ctx
.
helper
.
isPhoneNumber
(
phone
))
{
ctx
.
failed
(
'手机号不正确'
);
}
const
redisCode
=
await
ctx
.
app
.
memcache
.
get
(
`course_verify_code_
${
phone
}
`
);
if
(
!
ctx
.
isEmpty
(
redisCode
))
{
ctx
.
failed
(
'请勿频繁操作'
);
}
if
(
!
ctx
.
helper
.
isPhoneNumber
(
phone
))
{
ctx
.
failed
(
'手机号不正确'
);
}
const
code
=
await
this
.
getRandomNumber
(
5
);
const
now
=
String
(
new
Date
().
getTime
()
-
1000
);
...
...
@@ -32,7 +32,7 @@ class UserService extends Service {
sign
:
ctx
.
helper
.
md5
(
`
${
now
}
&
${
APP_KEY
}
`
),
params
:
{
phone
,
content
:
`您的验证码是:
${
code
}
,您正在登录趣选课,验证码5分内有效,请勿泄露给他人。`
,
content
:
`
【趣选课】
您的验证码是:
${
code
}
,您正在登录趣选课,验证码5分内有效,请勿泄露给他人。`
,
},
},
{
method
:
'POST'
,
...
...
@@ -41,7 +41,7 @@ class UserService extends Service {
timeout
:
[
5000
,
60000
],
});
if
(
ret
.
status
===
200
)
{
if
(
ret
.
status
===
20
1
||
ret
.
status
===
20
0
)
{
await
ctx
.
app
.
memcache
.
set
(
`course_verify_code_
${
phone
}
`
,
code
,
300
);
}
else
{
ctx
.
logger
.
info
(
'course_send_verify_code_error: '
+
JSON
.
stringify
(
ret
.
data
));
...
...
@@ -67,6 +67,10 @@ class UserService extends Service {
const
phone
=
input
.
phone
;
const
code
=
input
.
code
;
if
(
!
ctx
.
helper
.
isPhoneNumber
(
phone
))
{
ctx
.
failed
(
'手机号不正确'
);
}
// 判断用户是否存在
let
userInfo
=
await
ctx
.
classModel
.
V5
.
CourseUser
.
findOne
({
where
:
{
phone
,
is_deleted
:
0
}
});
if
(
ctx
.
isEmpty
(
userInfo
))
{
...
...
@@ -76,7 +80,8 @@ class UserService extends Service {
}
// 校验验证码
if
(
code
!==
'fuck'
)
{
const
redisCode
=
await
ctx
.
app
.
memcache
.
get
(
`course_verify_code_
${
phone
}
`
);
if
(
ctx
.
isEmpty
(
redisCode
)
||
code
!==
redisCode
)
{
ctx
.
failed
(
'验证码错误'
);
}
...
...
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