Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/constants/urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const APP_URLS = {
MY_STATUS: `${SCHEME}${DOMAIN}/status`,
API_BACKEND: `${SCHEME}api.${DOMAIN}`,
DASHBOARD: `${SCHEME}dashboard.${DOMAIN}`,
SIGN_UP: `${SCHEME}${DOMAIN}/new-signup`,
},
staging: {
HOME: `${SCHEME}staging-www.${DOMAIN}`,
Expand All @@ -31,6 +32,7 @@ const APP_URLS = {
MY_STATUS: `${SCHEME}staging-www.${DOMAIN}/status`,
API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`,
DASHBOARD: `${SCHEME}staging-dashboard.${DOMAIN}`,
SIGN_UP: `${SCHEME}staging-www.${DOMAIN}/new-signup`,
},
development: {
HOME: `${SCHEME}dev.${DOMAIN}`,
Expand All @@ -45,6 +47,7 @@ const APP_URLS = {
MY_STATUS: '/status',
DASHBOARD: `${SCHEME}staging-dashboard.${DOMAIN}`,
API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`,
SIGN_UP: `${SCHEME}dev.${DOMAIN}/new-signup`,
},
test: {
HOME: `${SCHEME}${DOMAIN}`,
Expand All @@ -59,6 +62,7 @@ const APP_URLS = {
MY_STATUS: `${SCHEME}${DOMAIN}/status`,
API_BACKEND: `${SCHEME}staging-api.${DOMAIN}`,
DASHBOARD: `${SCHEME}staging-dashboard.${DOMAIN}`,
SIGN_UP: '/new-signup',
},
};

Expand All @@ -73,7 +77,7 @@ export const ABOUT = {
export const AUTH = {
GITHUB_SIGN_IN: `${APPS.API_BACKEND}/auth/github/login`,
GOOGLE_SIGN_IN: `${APPS.API_BACKEND}/auth/google/login?dev=true`,
SIGN_UP: `${APPS.HOME}/new-signup`,
SIGN_UP: APPS.SIGN_UP,
};

export const SOCIALS = {
Expand Down
12 changes: 9 additions & 3 deletions app/services/login.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Service, { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { APPS, AUTH } from '../constants/urls';
import { APPS } from '../constants/urls';

export default class LoginService extends Service {
@service store;
Expand All @@ -9,6 +9,7 @@ export default class LoginService extends Service {
@tracked isLoading = true;
@service fastboot;
@service featureFlag;
@service router;

HeadersToCopy = ['Host', 'Cookie', 'User-Agent'];

Expand All @@ -31,8 +32,13 @@ export default class LoginService extends Service {
throw response;
})
.then((user) => {
if (user.incompleteUserDetails && !this.featureFlag.isDevMode)
window.location.replace(AUTH.SIGN_UP);
if (
user.incompleteUserDetails &&
!this.featureFlag.isDevMode &&
this.router.currentRoute?.name !== 'new-signup'
) {
this.router.replaceWith('/new-signup');
}
this.isLoggedIn = true;
this.userData = user;
})
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/routes/debug-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { module, test } from 'qunit';
import { setupTest } from 'website-www/tests/helpers';
import { visit } from '@ember/test-helpers';
import Service from '@ember/service';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this login stub is required to prevent flaky behaviour for tests with login redirect and from browser timeout issues

class LoginStub extends Service {
isLoading = false;
isLoggedIn = false;
userData = null;
}

module('Unit | Route | debug', function (hooks) {
setupTest(hooks);

hooks.beforeEach(function () {
this.owner.register('service:login', LoginStub);
});

test('it exists', function (assert) {
let route = this.owner.lookup('route:debug');
assert.ok(route);
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/routes/live-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { module, test } from 'qunit';
import { setupTest } from 'website-www/tests/helpers';
import { visit } from '@ember/test-helpers';
import Service from '@ember/service';

class LoginStub extends Service {
isLoading = false;
isLoggedIn = false;
userData = null;
}

module('Unit | Route | live', function (hooks) {
setupTest(hooks);

hooks.beforeEach(function () {
this.owner.register('service:login', LoginStub);
});
// TODO - remove tests for dev mode when it goes to prod
test('it exists', function (assert) {
let route = this.owner.lookup('route:live');
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/routes/login-test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import { module, test } from 'qunit';
import { setupTest } from 'website-www/tests/helpers';
import { visit, currentURL } from '@ember/test-helpers';
import Service from '@ember/service';

class LoginStub extends Service {
isLoading = false;
isLoggedIn = false;
userData = null;
}

module('Unit | Route | login', function (hooks) {
setupTest(hooks);

hooks.beforeEach(function () {
this.owner.register('service:login', LoginStub);
});

test('it exists', function (assert) {
let route = this.owner.lookup('route:login');
assert.ok(route);
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/routes/page-not-found-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import { module, test } from 'qunit';
import { setupTest } from 'website-www/tests/helpers';
import { visit } from '@ember/test-helpers';
import Service from '@ember/service';

class LoginStub extends Service {
isLoading = false;
isLoggedIn = false;
userData = null;
}

module('Unit | Route | page-not-found', function (hooks) {
setupTest(hooks);

hooks.beforeEach(function () {
this.owner.register('service:login', LoginStub);
});

test('it exists', function (assert) {
let route = this.owner.lookup('route:page-not-found');
assert.ok(route);
Expand Down