setup base jwt authentication
This commit is contained in:
18
app/adapters/application.js
Normal file
18
app/adapters/application.js
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user