File tree Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Expand file tree Collapse file tree 1 file changed +23
-6
lines changed Original file line number Diff line number Diff line change 11import { Accounts } from 'meteor/accounts-base'
22import { Meteor } from 'meteor/meteor'
33
4- export default async function ( root , { token } , { userId} ) {
5- const user = Meteor . users . findOne ( {
6- _id : userId ,
7- 'services.resume.loginTokens.hashedToken' : Accounts . _hashLoginToken ( token )
4+ export default async function ( root , { token } , context ) {
5+ let userId = null ;
6+
7+ const user = await Meteor . users . findOne ( {
8+ _id : context . userId ,
9+ 'services.resume.loginTokens.hashedToken' : Accounts . _hashLoginToken ( token ) ,
10+ } , {
11+ fields : {
12+ _id : 1 ,
13+ 'services.resume.loginTokens.$' : 1 ,
14+ } ,
815 } ) ;
16+
17+ if ( user ) {
18+ const loginToken = user . services . resume . loginTokens [ 0 ] ;
19+ const expiresAt = Accounts . _tokenExpiration ( loginToken . when ) ;
20+ const isExpired = expiresAt < new Date ( ) ;
21+
22+ if ( ! isExpired ) {
23+ userId = user . _id ;
24+ }
25+ }
926 return {
10- success : ! ! user ,
11- userId : user . _id || null
27+ success : ! ! userId ,
28+ userId
1229 } ;
1330}
You can’t perform that action at this time.
0 commit comments