2017-09-05 2 views
0

아래 코드는 현재 작동하지만 입니다. _setup을 사용하여 줄을 제거하면 나가는 요청에 Authorization 헤더가 없습니다.Ember Simple Auth - 세션 복원시 권한 부여자가 설정되지 않음

문서에 없으므로 _setup 함수를 사용해야한다고 생각하지 않습니다.

내가 뭘 잘못하고 있니?

Oauth 암호 부여와 함께 최신 버전의 Ember 및 Ember-Simple-Auth를 사용하고 있습니다.

Ember.getOwner(this).lookup('authenticator:custom').restore(token).then(() => { 
    Ember.getOwner(this).lookup('session:main')._setup('authenticator:custom', token, true); 
}); 

답변

0

복원은 앱 시작 및 저장 변경시 실행되는 편리한 기능입니다. 내가 아는 한, 수동으로 호출 할 의도는 없지만 앱 부팅시 자동으로 실행되고 세션 데이터에서 복원되어야합니다. 수동으로 복원을 호출하여 수행하려는 작업이 무엇이든 관계없이 토큰을 인수로 전달하여 대신 인증 훅 내부에서 처리 할 수 ​​있습니다. 사용자 정의 인증에

정규 호출이 내가하고 결국 무엇인가, 그것은 사람을 도움이 경우

session: Ember.inject.service('session'), 
    someFunction() { 
    let token = this.get('tokenSavedSomewhere') 
    this.get('session').authenticate('authenticator:custom', token).catch((reason) => { 
     console.log('Reject reason', reason) 
    }); 
    }, 
+0

를 application.js application.js. :) – NotHereAnymore

+1

쿨! 구현 공유 주셔서 감사합니다. – handlebears

1

처럼 보일 것이다.

노선/ (코드)

this.get('session').authenticate('authenticator:custom', token).catch((reason) => { 
    console.log('Reject reason', reason) 
})  

인증 자이 /이 거의 내가하고 결국 무엇

export default Authenticator.extend({ 
    authenticate(token) { 
    return this.restore(token); 
    } 
});