@ -13,13 +13,17 @@ class PasswordResetJob extends Job {
const User = this . models . get ( 'auth:User' )
const user = await User . findById ( user _id )
if ( ! user ) {
this . output. error( ` Unable to find user with ID: ${ user _id } ` )
this . error( ` Unable to find user with ID: ${ user _id } ` )
throw new Error ( 'Unable to find user with that ID.' )
}
this . output . info ( ` Resetting password for user: ${ user . uid } ` )
this . info ( ` Resetting password for user: ${ user . uid } ` )
// Create an authenticated key-action
const key _action = await this . key _action ( user )
this . info ( ` Created reset keyaction ${ key _action . id } (key: ${ key _action . key } , handler: ${ key _action . handler } ) ` )
await this . jobs . queue ( 'mailer' ) . add ( 'EMail' , {
to : user . email ,
subject : 'Reset Your Password | ' + this . configs . get ( 'app.name' ) ,
@ -34,17 +38,22 @@ class PasswordResetJob extends Job {
}
} )
this . info ( 'Logged e-mail job.' )
if ( user . notify _config && user . notify _config . active ) {
await user . notify _config . log ( {
title : ` ${ this . configs . get ( 'app.name' ) } : Password Reset Requested ` ,
message : ` A password reset request was logged for your account ( ${ user . uid } ). If this was you, please check your e-mail for further instructions. ` ,
priority : 8 ,
} )
this . info ( 'Logged security push notification job' )
}
this . output. success( 'Password reset logged.' )
this . success( 'Password reset logged.' )
} catch ( e ) {
this . output . error ( e )
this . error ( e )
throw e
}
}