Ok, i have figured it out. I have overridden verify method. I Am changing email_verified field using management API from inside verify function. Example code:
function verify (email, callback) {
const makeRequest = require('request');
const getManagementApiToken = async () => {
return new Promise((resolve, reject) => {
makeRequest({
method: 'POST',
url: `.../oauth/token`,
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
client_id: `...`,
client_secret: `...`,
audience: `.../api/v2/`,
grant_type: 'client_credentials'
})
}, (error, response) => {
if (!error) {
const token = JSON.parse(response.body).access_token
resolve(token)
}
})
})
}
const getUserByEmail = (token) => {
return new Promise((resolve, reject) => {
makeRequest({
method: 'GET',
url: `.../api/v2/users-by-email`,
headers: {
'content-type': 'application/json',
authorization: `Bearer ${token}`
},
qs: {
email
}
}, (error, response) => {
if (!error) {
resolve(JSON.parse(response.body)[0])
} else {
reject(error)
}
})
})
}
const changeEmailVerified = (userId, token) => {
return new Promise((resolve, reject) => {
makeRequest({
method: 'PATCH',
url: `.../api/v2/users/${userId}`,
headers: {
'content-type': 'application/json',
authorization: `Bearer ${token}`
},
body: JSON.stringify({
email_verified: true,
connection: '...'
})
}, (error, response) => {
if (!error) {
resolve(response)
} else {
reject(error)
}
})
})
}
const updateIsVerified = async () => {
const token = await getManagementApiToken()
const user = await getUserByEmail(token)
await changeEmailVerified(user.user_id, token)
callback(null, true)
}
updateIsVerified()
}