4

ToriiSimple-Auth Torii authenticator을 사용하여 페이스 북 로그인을 설정하려고했습니다. 나는 ember-cli를 사용하고 있습니다. 팝업은 승인을 요청 여는Torii 및 Simple-Auth의 Facebook 로그인 : 인증 데이터가 반환되지 않음

// app/controllers/login.js 
import Ember from 'ember'; 
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin'; 

export default Ember.Controller.extend(LoginControllerMixin, { 
    actions: { 
    authenticateWithTorii: function(){ 
     this.get('session').authenticate(
     'simple-auth-authenticator:torii', 
     'facebook-oauth2' 
    ).then(
     function(data) { 
      alert('SUCCESS ' + data); 
     }, 
     function(error) { 
      alert('There was an error when trying to sign you in: ' + error); 
     } 
    ); 
    } 
    } 
}); 

, 그때 나는 "성공 UNDEFINED"로 경고를 참조하십시오

// config/environment.js 
ENV['torii'] = { 
    providers: { 
     'facebook-oauth2': { 
      apiKey:  'my facebook app id' 
     } 
    } 
} 

여기 내 로그인 코드 :

여기 내 구성입니다. 내 백엔드에서 사용자 (액세스 토큰 또는 페이스 북의 uid 등)를 확실히 인증 할 수있는 데이터를 얻을 것이라고 생각했습니다.

Simple-Auth에서 Torii를 사용하는 방식에 뭔가 빠졌습니까?

답변

4

약속은 Session#authenticatedoes not have a value에 의해 반환되지만 토리 인증자가 해결하는 모든 내용은 인증 된 즉시 세션에서 사용할 수 있습니다 (반환 된 약속이 해결되면 사용자에게 있음). 예 :에 액세스 할 수 있습니다. 또한 세션의 content 속성을 검사 할 수 있습니다

var _this = this; 
this.get('session').authenticate(
    'simple-auth-authenticator:torii', 
    'facebook-oauth2' 
).then(function(data) { 
    alert('SUCCESS ' + _this.get('session.token')); 
}) 

와 (비공개의 당신이 그렇지 않으면 사용하지 말아야하지만 괜찮아요 디버깅 용) token 속성을 사용할 수 있는지 확인하려면 :

console.log(this.get('session.content'))