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');