Handle undefined Github access token

This commit is contained in:
2019-08-28 12:53:21 +02:00
parent dc5dfe19f2
commit 0625ee9d79
+12 -1
View File
@@ -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');