Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow different base path for fastboot #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
20 changes: 16 additions & 4 deletions addon/authenticators/mu-semtech.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export default class MuSemtechAuthenticator extends Base {
super(...arguments);
const config = getOwner(this).resolveRegistration('config:environment');
this.basePath = config['basePath'] || '/sessions';

if (this.isFastboot() && config['fastbootBasePath']) {
this.basePath = config['fastbootBasePath'];
}
}

async authenticate(options) {
Expand Down Expand Up @@ -71,12 +75,20 @@ export default class MuSemtechAuthenticator extends Base {
}

enrichHeadersOnFastboot(headers) {
// note we don't inject the service because we also support apps without fastboot
const fastboot = getOwner(this).lookup('service:fastboot');
if (fastboot && fastboot.isFastBoot) {
const fastbootHeaders = fastboot.request.headers;
if (this.isFastboot()) {
const fastbootHeaders = this.getFastboot().request.headers;
// note that this only works on fastboot, cookie is a forbidden header in the browser
headers.append('Cookie', fastbootHeaders.get('Cookie'));
}
}

isFastboot() {
const fastboot = this.getFastboot();
return fastboot && fastboot.isFastBoot;
}

getFastboot() {
// note we don't inject the service because we also support apps without fastboot
return getOwner(this).lookup('service:fastboot');
}
}