我已經按照項目自述的「天真」的實現:https://github.com/mondora/asteroid-oauth-mixin小行星的Oauth loginServiceConfiguration:「谷歌」的未定義
在我的代碼示例中的唯一差別是改變箭頭功能,傳統的這個用法。
asteroid.ddp.on("added", ({collection, id, fields}: { collection: string; fields: {}, id: string }) => {
if (collection === "meteor_accounts_loginServiceConfiguration") {
asteroid.loginServiceConfiguration = {
...asteroid.loginServiceConfiguration,
[id]: {
_id: id,
...fields
}
};
}
});
});
asteroid.getServiceConfig = function(providerName: string) { // ts file
return this.loginServiceConfiguration[providerName];
}
當我做asteroid.loginWith( '谷歌')
index.ts:50 Uncaught TypeError: Cannot read property 'google' of undefined
在流星後端我也裝meteor add accounts-base accounts-google
,因爲我認爲這是一種依賴。
我錯過了什麼?謝謝!
我試着加入DDP.loginServiceConfiguration = {}
超過該片段解決了錯誤,但創建一個新的錯誤之前。
asteroid-oauth-mixin.js:787 Uncaught TypeError: Cannot read property 'clientId' of undefined
at getOauthClientId (asteroid-oauth-mixin.js:787)
at Object.getOptions (asteroid-oauth-mixin.js:720)
at Asteroid.loginWith (asteroid-oauth-mixin.js:104)
at LoginForm../src/routes/accounts/auth/LoginForm.tsx.LoginForm.handleLoginWithGoogle (
而且當我運行meteor mongo
應該db.meteor_accounts_loginServiceConfiguration.find().count()
爲0?