From abf5fbbef639972ca07cb86da90e2df0f48a9aae Mon Sep 17 00:00:00 2001 From: SleepWalker Date: Tue, 25 Oct 2016 09:01:51 +0300 Subject: [PATCH] Fix register route blocked by oauth state restoration feature --- src/services/authFlow/AuthFlow.js | 6 ++++-- tests/services/authFlow/AuthFlow.test.js | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/services/authFlow/AuthFlow.js b/src/services/authFlow/AuthFlow.js index 8f48ff6..4c2b897 100644 --- a/src/services/authFlow/AuthFlow.js +++ b/src/services/authFlow/AuthFlow.js @@ -191,8 +191,10 @@ export default class AuthFlow { * @return {bool} - whether oauth state is being restored */ restoreOAuthState() { - // TODO: Свят, тут бага - return false; + if (this.getRequest().path.indexOf('/register') === 0) { + // allow register + return; + } try { const data = JSON.parse(localStorage.getItem('oauthData')); diff --git a/tests/services/authFlow/AuthFlow.test.js b/tests/services/authFlow/AuthFlow.test.js index 6372f02..b2b8d01 100644 --- a/tests/services/authFlow/AuthFlow.test.js +++ b/tests/services/authFlow/AuthFlow.test.js @@ -96,6 +96,12 @@ describe('AuthFlow', () => { expect(flow.setState, 'was called once'); }); + it('should not restore oauth state for /register route', () => { + flow.handleRequest({path: '/register'}); + + expect(flow.run, 'was not called'); // this.run('oAuthValidate'... + }); + it('should not restore outdated (>1h) oauth state', () => { localStorage.setItem('oauthData', JSON.stringify({ timestamp: Date.now() - 2 * 60 * 60 * 1000,