Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for auth getUserByPhoneNumber and listUsers methods #152

Open
mastepanoski opened this issue Aug 15, 2019 · 0 comments
Open

Comments

@mastepanoski
Copy link

mastepanoski commented Aug 15, 2019

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)
      })
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant