From 0625ee9d7945e207e56ce348f0bcd55bef938c69 Mon Sep 17 00:00:00 2001 From: Garret Alfert Date: Wed, 28 Aug 2019 12:53:21 +0200 Subject: [PATCH] Handle undefined Github access token --- app/routes/signup/github.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/routes/signup/github.js b/app/routes/signup/github.js index 969dc55..7ad6798 100644 --- a/app/routes/signup/github.js +++ b/app/routes/signup/github.js @@ -1,5 +1,6 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; +import { isEmpty } from '@ember/utils'; export default Route.extend({ @@ -8,7 +9,17 @@ export default Route.extend({ redirect () { this._super(...arguments); - const accessToken = window.location.hash.match(/access_token=(.+)/)[1]; + let accessToken; + try { + accessToken = window.location.hash.match(/access_token=(.+)/)[1]; + } catch (error) { /* ignore */ } + + if (isEmpty(accessToken) || accessToken === 'undefined') { + console.error('No GitHub access token found.'); + this.transitionTo('signup'); + return; + } + this.kredits.set('githubAccessToken', accessToken); this.transitionTo('signup.eth-account');