Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
ee1b86e3
Commit
ee1b86e3
authored
Oct 02, 2019
by
les
Browse files
[fix] password recovery
parent
4fe78aa3
Changes
1
Hide whitespace changes
Inline
Side-by-side
server/api/controller/user.js
View file @
ee1b86e3
...
...
@@ -184,12 +184,7 @@ const userController = {
if
(
!
recover_code
)
{
return
res
.
sendStatus
(
400
)
}
const
user
=
await
User
.
findOne
({
where
:
{
recover_code
:
{
[
Op
.
eq
]:
recover_code
}
}
})
if
(
!
user
)
{
return
res
.
sendStatus
(
400
)
}
try
{
await
user
.
update
({
recover_code
:
''
})
res
.
sendStatus
(
200
)
}
catch
(
e
)
{
res
.
sendStatus
(
400
)
}
},
async
updatePasswordWithRecoverCode
(
req
,
res
)
{
...
...
@@ -198,10 +193,8 @@ const userController = {
if
(
!
recover_code
||
!
password
)
{
return
res
.
sendStatus
(
400
)
}
const
user
=
await
User
.
findOne
({
where
:
{
recover_code
:
{
[
Op
.
eq
]:
recover_code
}
}
})
if
(
!
user
)
{
return
res
.
sendStatus
(
400
)
}
user
.
recover_code
=
''
user
.
password
=
password
try
{
await
user
.
save
(
)
await
user
.
update
({
recover_code
:
''
,
password
}
)
res
.
sendStatus
(
200
)
}
catch
(
e
)
{
res
.
sendStatus
(
400
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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