Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
c725f14bf2
|
|||
|
9b5216431d
|
@@ -12,7 +12,7 @@ class EMailJob extends Job {
|
|||||||
|
|
||||||
const { data } = job
|
const { data } = job
|
||||||
let { from = config.default_sender, to, subject, html = undefined, email_params = undefined } = data
|
let { from = config.default_sender, to, subject, html = undefined, email_params = undefined } = data
|
||||||
this.output.info(`Sending mail to ${to}...`)
|
this.info(`Sending mail to ${to}...`)
|
||||||
|
|
||||||
if ( !html && email_params ) html = this.email(email_params)
|
if ( !html && email_params ) html = this.email(email_params)
|
||||||
|
|
||||||
@@ -20,9 +20,11 @@ class EMailJob extends Job {
|
|||||||
from, to, subject, html,
|
from, to, subject, html,
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.output.error(e)
|
this.error(e)
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
this.output.success(`Mail sent!`)
|
|
||||||
|
this.success(`Mail sent!`)
|
||||||
}
|
}
|
||||||
|
|
||||||
email({ header_text, body_paragraphs = [], button_text = '', button_link = '' }) {
|
email({ header_text, body_paragraphs = [], button_text = '', button_link = '' }) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class ForeignIPLoginAlertJob extends Job {
|
|||||||
const user = await User.findById(user_id)
|
const user = await User.findById(user_id)
|
||||||
if ( !user ) throw new Error('Unable to find user with ID: '+user_id)
|
if ( !user ) throw new Error('Unable to find user with ID: '+user_id)
|
||||||
|
|
||||||
this.output.info('Sending foreign IP login alert to user.')
|
this.info('Sending foreign IP login alert to user ' + user.uid)
|
||||||
|
|
||||||
await this.jobs.queue('mailer').add('EMail', {
|
await this.jobs.queue('mailer').add('EMail', {
|
||||||
to: user.email,
|
to: user.email,
|
||||||
@@ -29,14 +29,19 @@ class ForeignIPLoginAlertJob extends Job {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.info('Logged e-mail job')
|
||||||
|
|
||||||
if ( user.notify_config && user.notify_config.active ) {
|
if ( user.notify_config && user.notify_config.active ) {
|
||||||
await user.notify_config.log({
|
await user.notify_config.log({
|
||||||
title: `${this.configs.get('app.name')}: Sign-In From New IP`,
|
title: `${this.configs.get('app.name')}: Sign-In From New IP`,
|
||||||
message: `Someone signed into your account (${user.uid}) from the IP address ${ip}. If this was you, no further action is required.`,
|
message: `Someone signed into your account (${user.uid}) from the IP address ${ip}. If this was you, no further action is required.`,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.info('Logged push notification job')
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.output.error(e)
|
this.error(e)
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,17 @@ class PasswordResetJob extends Job {
|
|||||||
const User = this.models.get('auth:User')
|
const User = this.models.get('auth:User')
|
||||||
const user = await User.findById(user_id)
|
const user = await User.findById(user_id)
|
||||||
if (!user) {
|
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.')
|
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
|
// Create an authenticated key-action
|
||||||
const key_action = await this.key_action(user)
|
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', {
|
await this.jobs.queue('mailer').add('EMail', {
|
||||||
to: user.email,
|
to: user.email,
|
||||||
subject: 'Reset Your Password | ' + this.configs.get('app.name'),
|
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 ) {
|
if ( user.notify_config && user.notify_config.active ) {
|
||||||
await user.notify_config.log({
|
await user.notify_config.log({
|
||||||
title: `${this.configs.get('app.name')}: Password Reset Requested`,
|
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.`,
|
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,
|
priority: 8,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.info('Logged security push notification job')
|
||||||
}
|
}
|
||||||
|
|
||||||
this.output.success('Password reset logged.')
|
this.success('Password reset logged.')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.output.error(e)
|
this.error(e)
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class PasswordResetAlertJob extends Job {
|
|||||||
const user = await User.findById(user_id)
|
const user = await User.findById(user_id)
|
||||||
if ( !user ) throw new Error('Unable to find user with ID: '+user_id)
|
if ( !user ) throw new Error('Unable to find user with ID: '+user_id)
|
||||||
|
|
||||||
this.output.info('Sending password reset alert to user.')
|
this.info('Sending password reset alert to user ' + user.uid)
|
||||||
|
|
||||||
await this.jobs.queue('mailer').add('EMail', {
|
await this.jobs.queue('mailer').add('EMail', {
|
||||||
to: user.email,
|
to: user.email,
|
||||||
@@ -28,15 +28,20 @@ class PasswordResetAlertJob extends Job {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.info('Logged e-mail job')
|
||||||
|
|
||||||
if ( user.notify_config && user.notify_config.active ) {
|
if ( user.notify_config && user.notify_config.active ) {
|
||||||
await user.notify_config.log({
|
await user.notify_config.log({
|
||||||
title: `${this.configs.get('app.name')}: Password Reset`,
|
title: `${this.configs.get('app.name')}: Password Reset`,
|
||||||
message: `The password to your account (${user.uid}) was reset from the IP address ${ip}. If this was not you, please contact your system administrator.`,
|
message: `The password to your account (${user.uid}) was reset from the IP address ${ip}. If this was not you, please contact your system administrator.`,
|
||||||
priority: 8,
|
priority: 8,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.info('Logged push notification job')
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.output.error(e)
|
this.error(e)
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,14 +14,15 @@ class PopulateAnnouncementJob extends Job {
|
|||||||
const announcement = await Announcement.findById(announcement_id)
|
const announcement = await Announcement.findById(announcement_id)
|
||||||
|
|
||||||
if ( !announcement ) {
|
if ( !announcement ) {
|
||||||
this.output.error(`Unable to find announcement with ID: ${announcement_id}`)
|
this.error(`Unable to find announcement with ID: ${announcement_id}`)
|
||||||
throw new Error('Unable to find announcement with that ID.')
|
throw new Error('Unable to find announcement with that ID.')
|
||||||
}
|
}
|
||||||
|
|
||||||
await announcement.populate()
|
await announcement.populate()
|
||||||
this.output.success('Populated announcements.')
|
this.success('Populated announcements.')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.output.error(e)
|
this.error(e)
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,15 @@ class PushNotifyJob extends Job {
|
|||||||
const notify = user.notify_config
|
const notify = user.notify_config
|
||||||
if ( !notify || !notify.active ) throw new Error('User does not have notifications configured.')
|
if ( !notify || !notify.active ) throw new Error('User does not have notifications configured.')
|
||||||
|
|
||||||
this.output.info(`Sending notification to ${user.uid}...`)
|
this.info(`Sending notification to ${user.uid}...`)
|
||||||
|
|
||||||
await notify.send({ title, message, priority })
|
await notify.send({ title, message, priority })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.output.error(e)
|
this.error(e)
|
||||||
|
throw e
|
||||||
}
|
}
|
||||||
this.output.success(`Notification sent!`)
|
|
||||||
|
this.success(`Notification sent!`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
"flitter-forms": "^0.8.1",
|
"flitter-forms": "^0.8.1",
|
||||||
"flitter-gotify": "^0.1.0",
|
"flitter-gotify": "^0.1.0",
|
||||||
"flitter-i18n": "^0.1.1",
|
"flitter-i18n": "^0.1.1",
|
||||||
"flitter-jobs": "^0.3.0",
|
"flitter-jobs": "^0.4.0",
|
||||||
"flitter-less": "^0.5.3",
|
"flitter-less": "^0.5.3",
|
||||||
"flitter-orm": "^0.4.0",
|
"flitter-orm": "^0.4.0",
|
||||||
"flitter-redis": "^0.1.1",
|
"flitter-redis": "^0.1.1",
|
||||||
|
|||||||
@@ -2148,10 +2148,10 @@ flitter-i18n@^0.1.1:
|
|||||||
ncp "^2.0.0"
|
ncp "^2.0.0"
|
||||||
pluralize "^8.0.0"
|
pluralize "^8.0.0"
|
||||||
|
|
||||||
flitter-jobs@^0.3.0:
|
flitter-jobs@^0.4.0:
|
||||||
version "0.3.0"
|
version "0.4.0"
|
||||||
resolved "https://registry.yarnpkg.com/flitter-jobs/-/flitter-jobs-0.3.0.tgz#c10fd45e4ab3c41c32ad4d8540b9b76547c20fbd"
|
resolved "https://registry.yarnpkg.com/flitter-jobs/-/flitter-jobs-0.4.0.tgz#6871f611fddb43e8e0ecdb144743ada967aedf8a"
|
||||||
integrity sha512-uapjauWZCoZwc+3DuL0W1tY4LozSXTr3FqrKJEcL/Ri8diRYjZuT0+v+kiZBJ4YzThcjjXF+aYoFL09QlIG7Zw==
|
integrity sha512-L7SPCzxR+pR9LflWOsChkalhLav7YSES79dv7N8VEFpQuhXZ01jm0MwUnKMJyS9+QOiogDzQuab7IsVdMojUFQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
bullmq "^1.8.8"
|
bullmq "^1.8.8"
|
||||||
flitter-redis "^0.1.1"
|
flitter-redis "^0.1.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user