The authentication API has two methods. Here I provide a possible implementation:
function getUserByPhoneNumber(phone, onComplete) {
return new Promise(function (resolve, reject) {
const result = _.find(self, self._auth.users, item => {
return item.phoneNumber === phone
})
if (result) {
if (onComplete) {
onComplete(null, result.clone())
}
resolve(result.clone())
} else {
const err = new Error('auth/user-not-found')
if (onComplete) {
onComplete(err, null)
}
reject(err)
}
})
}
function listUsers(limit, token = 0) {
return new Promise(function (resolve) {
const users = self_auth.users.slice(token, token + limit)
// Return list of user records and the next page token if available.
const result = {
users,
pageToken: (token + limit + 1) < self._auth.users.length ? token + 1 : null
}
if (!result.pageToken) {
delete result.pageToken
}
resolve(result)
})
}
The authentication API has two methods. Here I provide a possible implementation: