1

我正在尝试在我的 Ember 应用程序中使用 Google 和 Facebook 进行身份验证,但我无法正确配置它。我在 google 开发者网站上创建了这个项目,添加了 oAuth,并在 Firebase 上启用了 Google。我在https://www.firebase.com/docs/web/libraries/ember/guide.html上按照以下步骤操作:

ember install torii

    // config/environment.js
/* ... */
    firebase: 'https://YOUR-FIREBASE-NAME.firebaseio.com/',
    torii: {
      sessionServiceName: 'session'
    }
/* ... */




// torii-adapters/application.js
import Ember from 'ember';
import ToriiFirebaseAdapter from 'emberfire/torii-adapters/firebase';
export default ToriiFirebaseAdapter.extend({
  firebase: Ember.inject.service()
});




    // app/routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
  beforeModel: function() {
    return this.get("session").fetch().catch(function() {});
  },
  actions: {
    signIn: function(provider) {
      this.get("session").open("firebase", { provider:provider}).then(function(data) {
        console.log(data.currentUser);
      });
    },
    signOut: function() {
      this.get("session").close();
    }
  }
});



    // app/templates/application.hbs
{{#if session.isAuthenticated}}
  Logged in as {{session.currentUser.displayName}}
  <button {{action "signOut"}}>Sign out</button>
  {{outlet}}
{{else}}
  <button {{action "signIn" "twitter"}}>Sign in with Twitter</button>
{{/if}}

我也不知道把这个片段放在哪里: this.get('session').open('firebase', { provider: 'password', email: 'test@example.com', password: 'password1234' }) ;

这些是我得到的错误:

Error while processing route: profile this.get(...) is undefined beforeModel@http://localhost:4200/assets/announce-me.js:245:14
applyHook@http://localhost:4200/assets/vendor.js:61326:16
HandlerInfo.prototype.runSharedModelHook@http://localhost:4200/assets/vendor.js:59517:20
HandlerInfo.prototype.runBeforeModelHook@http://localhost:4200/assets/vendor.js:59491:14
bind/<@http://localhost:4200/assets/vendor.js:61196:14
tryCatch@http://localhost:4200/assets/vendor.js:61543:14
invokeCallback@http://localhost:4200/assets/vendor.js:61558:15
publish@http://localhost:4200/assets/vendor.js:61526:9
@http://localhost:4200/assets/vendor.js:41428:7
Queue.prototype.invoke@http://localhost:4200/assets/vendor.js:10459:9
Queue.prototype.flush@http://localhost:4200/assets/vendor.js:10523:11
DeferredActionQueues.prototype.flush@http://localhost:4200/assets/vendor.js:10331:11
Backburner.prototype.end@http://localhost:4200/assets/vendor.js:10686:9
Backburner.prototype.run@http://localhost:4200/assets/vendor.js:10808:13
Backburner.prototype.join@http://localhost:4200/assets/vendor.js:10828:16
run.join@http://localhost:4200/assets/vendor.js:30439:12
run.bind/<@http://localhost:4200/assets/vendor.js:30502:14
jQuery.Callbacks/fire@http://localhost:4200/assets/vendor.js:3498:11
jQuery.Callbacks/self.fireWith@http://localhost:4200/assets/vendor.js:3628:7
.ready@http://localhost:4200/assets/vendor.js:3847:3
completed@http://localhost:4200/assets/vendor.js:3863:2
 vendor.js:37856:5

beforeModel@http://localhost:4200/assets/announce-me.js:245:14
applyHook@http://localhost:4200/assets/vendor.js:61326:16
HandlerInfo.prototype.runSharedModelHook@http://localhost:4200/assets/vendor.js:59517:20
HandlerInfo.prototype.runBeforeModelHook@http://localhost:4200/assets/vendor.js:59491:14
bind/<@http://localhost:4200/assets/vendor.js:61196:14
tryCatch@http://localhost:4200/assets/vendor.js:61543:14
invokeCallback@http://localhost:4200/assets/vendor.js:61558:15
publish@http://localhost:4200/assets/vendor.js:61526:9
@http://localhost:4200/assets/vendor.js:41428:7
Queue.prototype.invoke@http://localhost:4200/assets/vendor.js:10459:9
Queue.prototype.flush@http://localhost:4200/assets/vendor.js:10523:11
DeferredActionQueues.prototype.flush@http://localhost:4200/assets/vendor.js:10331:11
Backburner.prototype.end@http://localhost:4200/assets/vendor.js:10686:9
Backburner.prototype.run@http://localhost:4200/assets/vendor.js:10808:13
Backburner.prototype.join@http://localhost:4200/assets/vendor.js:10828:16
run.join@http://localhost:4200/assets/vendor.js:30439:12
run.bind/<@http://localhost:4200/assets/vendor.js:30502:14
jQuery.Callbacks/fire@http://localhost:4200/assets/vendor.js:3498:11
jQuery.Callbacks/self.fireWith@http://localhost:4200/assets/vendor.js:3628:7
.ready@http://localhost:4200/assets/vendor.js:3847:3
completed@http://localhost:4200/assets/vendor.js:3863:2
4

1 回答 1

0

Torii-firebase 的提供者。

https://github.com/firebase/emberfire

也许你已经看过了?

杰夫

于 2016-07-03T01:09:05.430 回答