Fix register route blocked by oauth state restoration feature

This commit is contained in:
SleepWalker 2016-10-25 09:01:51 +03:00
parent 38196e8f76
commit abf5fbbef6
2 changed files with 10 additions and 2 deletions

View File

@ -191,8 +191,10 @@ export default class AuthFlow {
* @return {bool} - whether oauth state is being restored * @return {bool} - whether oauth state is being restored
*/ */
restoreOAuthState() { restoreOAuthState() {
// TODO: Свят, тут бага if (this.getRequest().path.indexOf('/register') === 0) {
return false; // allow register
return;
}
try { try {
const data = JSON.parse(localStorage.getItem('oauthData')); const data = JSON.parse(localStorage.getItem('oauthData'));

View File

@ -96,6 +96,12 @@ describe('AuthFlow', () => {
expect(flow.setState, 'was called once'); 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', () => { it('should not restore outdated (>1h) oauth state', () => {
localStorage.setItem('oauthData', JSON.stringify({ localStorage.setItem('oauthData', JSON.stringify({
timestamp: Date.now() - 2 * 60 * 60 * 1000, timestamp: Date.now() - 2 * 60 * 60 * 1000,