small works
This commit is contained in:
@@ -5,14 +5,21 @@ import { inject as service } from '@ember/service';
|
||||
export default class ApplicationAdapter extends JSONAPIAdapter {
|
||||
@service session;
|
||||
|
||||
namespace = 'api/v1';
|
||||
get namespace() {
|
||||
if (this.session.isAuthenticated) {
|
||||
return 'api/v1';
|
||||
} else {
|
||||
return 'api/v1/public';
|
||||
}
|
||||
}
|
||||
|
||||
@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}`;
|
||||
headers['Authorization'] =
|
||||
`Bearer ${this.session.data.authenticated.access_token}`;
|
||||
}
|
||||
|
||||
return headers;
|
||||
|
||||
Reference in New Issue
Block a user