feat: 🎸 add org nav to header

This commit is contained in:
Randall Morey committed 2020-10-01 13:15:45 -04:00
1 parent 5f57a0d373
commit 7c869b623f
6 files changed
+51 -12

No files matched your search

+15 -2
View File
@@ -64,7 +64,7 @@ export default class PasswordAuthenticator extends BaseAuthenticator {
case 404:
return reject();
}
return resolve(data);
return resolve(this.normalizeData(data));
}
/**
@@ -93,7 +93,20 @@ export default class PasswordAuthenticator extends BaseAuthenticator {
const authEndpointURL = this.buildAuthEndpointURL(options);
const response = await fetch(authEndpointURL, { method: 'post', body });
const json = await response.json();
return response.status < 400 ? resolve(json) : reject();
return response.status < 400 ? resolve(this.normalizeData(json)) : reject();
}
/**
* Normalizes the auth data. Adds convenience booleans depending on the
* scope within which the session is authenticated: isGlobal, isOrg.
* @param {object} data
* @return {object}
*/
normalizeData(data) {
// Add booleans indicated the scope type
data.isGlobal = (data?.scope?.type === 'global');
data.isOrg = (data?.scope?.type === 'org');
return data;
}
/**