Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simcaq-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simcaq
simcaq-node
Commits
e27ee336
There was a problem fetching the pipeline summary.
Commit
e27ee336
authored
7 years ago
by
Gustavo Soviersovski
Browse files
Options
Downloads
Patches
Plain Diff
Attempting expire token
parent
2d451c3b
No related branches found
No related tags found
1 merge request
!116
Release v1.0.0
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/models/resetToken.js
+5
-3
5 additions, 3 deletions
src/libs/models/resetToken.js
src/libs/routes/resetToken.js
+10
-0
10 additions, 0 deletions
src/libs/routes/resetToken.js
with
15 additions
and
3 deletions
src/libs/models/resetToken.js
+
5
−
3
View file @
e27ee336
...
...
@@ -25,9 +25,7 @@ let ResetToken = new Schema({
required
:
true
,
default
:
Date
.
now
}
},
{
timestamps
:
true
});
ResetToken
.
index
({
createdAt
:
1
},{
expireAfterSeconds
:
86400
});
//Expire After a Day
});
ResetToken
.
methods
.
createResetToken
=
function
(
done
)
{
let
resetToken
=
this
;
...
...
@@ -40,5 +38,9 @@ ResetToken.methods.createResetToken = function (done) {
return
done
(
null
,
token
);
})
}
Token
.
methods
.
hasExpired
=
function
()
{
var
now
=
new
Date
();
return
(
now
-
createdAt
)
>
10
/*86400*/
;
//Token is a day old
};
module
.
exports
=
mongoose
.
model
(
'
ResetToken
'
,
ResetToken
);
This diff is collapsed.
Click to expand it.
src/libs/routes/resetToken.js
+
10
−
0
View file @
e27ee336
...
...
@@ -24,6 +24,16 @@ resetTokenApp.get('/:token', (req, res, next) => {
res
.
statusCode
=
404
;
return
next
({
msg
:
'
Token not found
'
,
status
:
404
});
}
if
(
rToken
.
hasExpired
())
{
res
.
statusCode
=
410
;
ResetToken
.
remove
({
token
:
token
},
(
err
)
=>
{
if
(
err
)
{
log
.
error
(
err
);
next
(
err
);
}
})
return
next
({
msg
:
'
Token expired
'
,
status
:
410
});
}
User
.
findById
(
rToken
.
userId
,
(
err
,
user
)
=>
{
if
(
err
)
{
log
.
error
(
err
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment