Skip to content

Commit

Permalink
Update verificationAPI.js
Browse files Browse the repository at this point in the history
  • Loading branch information
serdiukov-o-nordwhale committed May 27, 2020
1 parent be17c67 commit f8037c4
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/server/verification/verificationAPI.js
@@ -1,7 +1,7 @@
// @flow
import { Router } from 'express'
import passport from 'passport'
import _ from 'lodash'
import { get, defaults } from 'lodash'
import moment from 'moment'
import type { LoggedUser, StorageAPI, UserRecord, VerificationAPI } from '../../imports/types'
import AdminWallet from '../blockchain/AdminWallet'
Expand Down Expand Up @@ -71,7 +71,7 @@ const setup = (app: Router, verifier: VerificationAPI, storage: StorageAPI) => {
let enrollmentResult

try {
const { skipFaceVerification } = conf
const { skipFaceVerification, claimQueueAllowed } = conf
const enrollmentProcessor = createEnrollmentProcessor(storage)

enrollmentProcessor.validate(user, enrollmentIdentifier, payload)
Expand Down Expand Up @@ -112,10 +112,13 @@ const setup = (app: Router, verifier: VerificationAPI, storage: StorageAPI) => {
}
}
} else {
//only approved users can do the process
const isApprovedToClaim = user.claimQueue && ['approved', 'whitelisted'].includes(user.claimQueue.status)
if (conf.claimQueueAllowed > 0 && isApprovedToClaim === false)
const isApprovedToClaim = ['approved', 'whitelisted'].includes(get(user, 'claimQueue.status'))

// only approved users can do the process
if (claimQueueAllowed && !isApprovedToClaim) {
throw new Error('User not approved to claim, not in queue or still pending')
}

enrollmentResult = await enrollmentProcessor.enroll(user, enrollmentIdentifier, payload, log)
}
} catch (exception) {
Expand Down Expand Up @@ -153,7 +156,7 @@ const setup = (app: Router, verifier: VerificationAPI, storage: StorageAPI) => {

const mobile = body.user.mobile || user.otp.mobile

let userRec: UserRecord = _.defaults(body.user, user, { identifier: user.loggedInAs })
let userRec: UserRecord = defaults(body.user, user, { identifier: user.loggedInAs })
const savedMobile = user.mobile

if (conf.allowDuplicateUserData === false && (await storage.isDupUserData({ mobile }))) {
Expand Down Expand Up @@ -320,7 +323,7 @@ const setup = (app: Router, verifier: VerificationAPI, storage: StorageAPI) => {
const { email } = body.user

//merge user details for use by mautic
let userRec: UserRecord = _.defaults(body.user, user)
let userRec: UserRecord = defaults(body.user, user)
const currentEmail = user.email
const tempMauticId = user.otp && user.otp.tempMauticId

Expand Down

0 comments on commit f8037c4

Please sign in to comment.