Skip to content

Commit a0dbf8c

Browse files
committed
Only add admin auth headers if auth data is present.
This prevents the initial /admin/auth request (prior to authorizing the user) from having an api key of "undefined" passed along.
1 parent 8f480d0 commit a0dbf8c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/api-umbrella/admin-ui/app/instance-initializers/jquery-ajax.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@ export function initialize(appInstance) {
44
const session = appInstance.lookup('service:session');
55
$.ajaxPrefilter(function(options) {
66
const data = session.get('data.authenticated');
7-
options.headers = options.headers || {};
8-
options.headers['X-Api-Key'] = data.api_key;
9-
options.headers['X-Admin-Auth-Token'] = data.admin_auth_token;
7+
if(data) {
8+
options.headers = options.headers || {};
9+
10+
if(data.api_key) {
11+
options.headers['X-Api-Key'] = data.api_key;
12+
}
13+
14+
if(data.admin_auth_token) {
15+
options.headers['X-Admin-Auth-Token'] = data.admin_auth_token;
16+
}
17+
}
1018
});
1119
}
1220

0 commit comments

Comments
 (0)