Facebook account kit, nodejs api, mongodb


#1

Hi everybody,
I am new in ionic nodejs and mongodb so I’ll try my best!
I want to create a user with:

  • facebook account kit in my ionic 3
  • project with a NodJs API
  • connected to mongodb

I have used the cordova-plugin-accountkit. and set up correctly where I receive data
this is my registation.ts:

phonelogin(){
    (<any>window)
      .AccountKitPlugin
        .loginWithPhoneNumber({
          useAccessToken: true,
          defaultCountryCode: "FR",
          facebookNotificationsEnabled: true
        }, (successdata) => {
          (<any>window).AccountKitPlugin.getAccount((user) => {
            console.log( JSON.stringify(user.name) );
          })
        }, (err) => {
          alert(err);
        })
  }

this is the data I received from facebook accoutkit to ionic :

{
"accountId":"<accountId>",
"applicationId":"<APP_ID>",
"token":"<thetoken>",
"lastRefresh":1528884782327,
"refreshInterval":2592000,
"phoneNumber":"<phonenumber>"
}

for my nodejs API I followed this tutorial and I’ve included in my app.js :

github

this is the structure a my nodejs api

|__ server
    |__ api
    |   |__(exemple:) user
    |       |__ index.js, user.controller.js, user.event.js, user.integration.js, user.model.js others...
    |__auth
    |    |__(exemple: facebook and local)
    |    |    |__ index.js ,passport.js
    |    |__auth.service.js, index.js
    |__ componants
    |    |__email, errors, orderStatus
    |__ config
    |    |__ environment
    |    |    |__ development.js, index.js, production.js, shared.js, test.js
    |    |__express.js, local.env.js, local.env.sample.js, seed.js, socketio.js
    |__ views
    |    |__ 404.html
    |__app.js, index.js, routes.js

What I expect to do now is

  • send the token to the nodejs api from ionic front end
  • send the successful login to ionic
  • storing data of the new user in mongodb

Please help me hope it is clear