11import { Meteor } from 'meteor/meteor'
2- import * as _ from 'underscore'
32import { Accounts } from 'meteor/accounts-base'
43import { unprotectString , protectString } from '../lib/tempLib'
54import { sleep , deferAsync } from '../lib/lib'
@@ -25,7 +24,7 @@ async function enrollUser(email: string, name: string): Promise<UserId> {
2524 profile : { name : name } ,
2625 } )
2726 try {
28- Accounts . sendEnrollmentEmail ( unprotectString ( id ) , email )
27+ await Accounts . sendEnrollmentEmail ( unprotectString ( id ) , email )
2928 } catch ( error ) {
3029 logger . error ( 'Accounts.sendEnrollmentEmail' )
3130 logger . error ( error )
@@ -63,11 +62,13 @@ async function sendVerificationEmail(userId: UserId) {
6362 const user = await Users . findOneAsync ( userId )
6463 if ( ! user ) throw new Meteor . Error ( 404 , `User "${ userId } " not found!` )
6564 try {
66- _ . each ( user . emails , ( email ) => {
67- if ( ! email . verified ) {
68- Accounts . sendVerificationEmail ( unprotectString ( user . _id ) , email . address )
69- }
70- } )
65+ await Promise . all (
66+ user . emails . map ( async ( email ) => {
67+ if ( ! email . verified ) {
68+ await Accounts . sendVerificationEmail ( unprotectString ( user . _id ) , email . address )
69+ }
70+ } )
71+ )
7172 } catch ( error ) {
7273 logger . error ( 'ERROR sending email verification' )
7374 logger . error ( error )
@@ -79,7 +80,7 @@ async function requestResetPassword(email: string): Promise<boolean> {
7980 const meteorUser = Accounts . findUserByEmail ( email ) as unknown
8081 const user = meteorUser as User
8182 if ( ! user ) return false
82- Accounts . sendResetPasswordEmail ( unprotectString ( user . _id ) )
83+ await Accounts . sendResetPasswordEmail ( unprotectString ( user . _id ) )
8384 return true
8485}
8586
0 commit comments