mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-28 16:00:24 +05:30
Fix bug with infinite loader, when page refreshed on /login with oauth state restoration active
This commit is contained in:
parent
abf5fbbef6
commit
28ce3e4b70
@ -89,9 +89,9 @@ function restoreScroll() {
|
||||
/* global process: false */
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
// some shortcuts for testing on localhost
|
||||
window.testOAuth = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=http%3A%2F%2Fely.by&response_type=code&scope=minecraft_server_session';
|
||||
window.testOAuthStatic = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=static_page_with_code&response_type=code&scope=minecraft_server_session';
|
||||
window.testOAuthStaticCode = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=static_page&response_type=code&scope=minecraft_server_session';
|
||||
window.testOAuth = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=http%3A%2F%2Fely.by%2Fauthorization%2Foauth&response_type=code&scope=account_info%2Caccount_email';
|
||||
window.testOAuthStatic = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=static_page_with_code&response_type=code&scope=account_info%2Caccount_email';
|
||||
window.testOAuthStaticCode = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=static_page&response_type=code&scope=account_info%2Caccount_email';
|
||||
|
||||
// expose Perf
|
||||
window.Perf = require('react-addons-perf');
|
||||
|
@ -202,7 +202,8 @@ export default class AuthFlow {
|
||||
|
||||
if (Date.now() - data.timestamp < expirationTime) {
|
||||
this.run('oAuthValidate', data.payload)
|
||||
.then(() => this.setState(new CompleteState()));
|
||||
.then(() => this.setState(new CompleteState()))
|
||||
.then(() => this.onReady());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -58,7 +58,8 @@ describe('AuthFlow', () => {
|
||||
}));
|
||||
|
||||
sinon.stub(flow, 'run').named('flow.run');
|
||||
flow.run.returns({then: (fn) => fn()});
|
||||
const promiseLike = {then: (fn) => fn() || promiseLike};
|
||||
flow.run.returns(promiseLike);
|
||||
sinon.stub(flow, 'setState').named('flow.setState');
|
||||
});
|
||||
|
||||
@ -96,6 +97,14 @@ describe('AuthFlow', () => {
|
||||
expect(flow.setState, 'was called once');
|
||||
});
|
||||
|
||||
it('should call onReady after state restoration', () => {
|
||||
const onReady = sinon.stub().named('onReady');
|
||||
|
||||
flow.handleRequest({path: '/login'}, null, onReady);
|
||||
|
||||
expect(onReady, 'was called');
|
||||
});
|
||||
|
||||
it('should not restore oauth state for /register route', () => {
|
||||
flow.handleRequest({path: '/register'});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user