Skip to content

Commit

Permalink
fix: double-issued employee pass
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Apr 27, 2018
1 parent 0a10eac commit cda351b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/in-house-bot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,16 @@ const tweakProductListPerRecipient = (components: IBotComponents) => {

const approveWhenTheTimeComes = (components:IBotComponents):IPluginLifecycleMethods => {
const { bot, logger, conf, productsAPI, employeeManager, applications } = components
const { autoApprove } = conf.bot.products
const { autoApprove, approveAllEmployees } = conf.bot.products
const onFormsCollected = async ({ req, user, application }) => {
if (application.draft) return

if (!isPendingApplication({ user, application })) return
if (approveAllEmployees && application.requestFor === EMPLOYEE_ONBOARDING) {
// handled by bot-employee-manager
// yes...this is a bit confusing
return
}

if (!autoApprove) {
const results = await Promise.all([
Expand Down
8 changes: 7 additions & 1 deletion src/in-house-bot/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,14 @@ const hasApplication = (stubs, application) => {
return stubs.find(stub => stub.statePermalink === application._permalink)
}

const judgedStatuses = [
'approved',
'denied'
]

export const isPendingApplication = ({ user, application }) => {
return hasApplication(user.applications || [], application)
return !judgedStatuses.includes(application.status) &&
hasApplication(user.applications || [], application)
}

export const getApplicationStatus = ({ user, application }) => {
Expand Down

0 comments on commit cda351b

Please sign in to comment.