forked from OpenWF/SpaceNinjaServer
		
	chore: don't validate Nonce in query (#1341)
By asking MongoDB to simply find the account by the ID and then validating the nonce ourselves, we save roughly 1ms. Reviewed-on: OpenWF/SpaceNinjaServer#1341
This commit is contained in:
		
							parent
							
								
									d9b944175a
								
							
						
					
					
						commit
						a622393933
					
				@ -74,11 +74,8 @@ export const getAccountForRequest = async (req: Request): Promise<TAccountDocume
 | 
				
			|||||||
        throw new Error("Request is missing nonce parameter");
 | 
					        throw new Error("Request is missing nonce parameter");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const account = await Account.findOne({
 | 
					    const account = await Account.findById(req.query.accountId);
 | 
				
			||||||
        _id: req.query.accountId,
 | 
					    if (!account || account.Nonce != nonce) {
 | 
				
			||||||
        Nonce: nonce
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
    if (!account) {
 | 
					 | 
				
			||||||
        throw new Error("Invalid accountId-nonce pair");
 | 
					        throw new Error("Invalid accountId-nonce pair");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (account.Dropped && req.query.ct) {
 | 
					    if (account.Dropped && req.query.ct) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user