0
私のアプリケーションはMeteorから完全に分離されたReactで構築されています。バックエンドとしてのみ機能するMeteorとのインターフェースには小惑星を使用します。フロントエンドでFacebookのログインボタンを手動で作成し、FacebookからフェッチしたデータをAccounts.createUser
に渡したいと思います。私は以下のようにメソッドを作成しているAccounts.createUserユーザー名、パスワード、電子メールなし
const data = {
services: {
facebook: fb
},
profile: {
first_name: fb.first_name,
last_name: fb.last_name,
}
}
が、私は、適切なトークンまたは何流星が必要で、これまでの指標としてユーザーをログインに失敗しました:私はそうのようにそれをフォーマットしているので、この方法は利用できない二つのパラメータを要求します:
getLoginByExternalService(options) {
if (Meteor.userId()) throw new Meteor.Error('400',`Please logout ${Meteor.userId()}`);
const email = options.services.facebook.email
const facebookId = options.services.facebook.id
const user = {services: {}}
user.services = options.services
const users = Meteor.users.find({"services.facebook.id": facebookId}).fetch();
if (!users.length) {
const userId = Accounts.insertUserDoc(options, user)
if (Meteor.isServer)
this.setUserId(userId)
else
Meteor.setUserId(userId)
return userId
} else {
if (Meteor.isServer)
this.setUserId(users[0]._id)
if (Meteor.isClient)
Meteor.setUserId(userId)
return {users, userId: Meteor.userId()}
}
}
正しくログインするには?