简体   繁体   English

通过谷歌在ember中进行身份验证

[英]Authentication through google in ember

I am trying to get Authentication with Google and Facebook in my Ember app, but I cannot properly configure it. 我想在我的Ember应用程序中使用Google和Facebook进行身份验证,但我无法正确配置它。 I created the project on the google developer website, added oAuth, and enabled Google on Firebase. 我在google开发者网站上创建了该项目,添加了oAuth,并在Firebase上启用了Google。 I followed these steps on https://www.firebase.com/docs/web/libraries/ember/guide.html : 我在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}}

I also have no idea where to put this snippet: this.get('session').open('firebase', { provider: 'password', email: 'test@example.com', password: 'password1234' }); 我也不知道在哪里放这个片段:this.get('session')。open('firebase',{provider:'password',email:'test@example.com',密码:'password1234'}) ;

These are the errors that I was getting: 这些是我得到的错误:

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

Torii-provider for firebase. Torii- firebase供应商。

https://github.com/firebase/emberfire

Maybe you've already looked at it? 也许你已经看过了吗?

Jeff 杰夫

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM