setup base jwt authentication

This commit is contained in:
2025-01-06 21:34:23 +01:00
parent e91d6540bf
commit cf15e3beb3
12 changed files with 425 additions and 6 deletions

View File

@@ -0,0 +1,18 @@
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
export default class ApplicationAdapter extends JSONAPIAdapter {
@service session;
@computed('session.{data.authenticated.access_token,isAuthenticated}')
get headers() {
let headers = {};
if (this.session.isAuthenticated) {
// OAuth 2
headers['Authorization'] = `Bearer ${this.session.data.authenticated.access_token}`;
}
return headers;
}
}