feat: 🎸 add API and mock support for primary auth methods

This commit is contained in:
Randall Morey committed 2021-03-24 18:36:34 -04:00
1 parent 22d578620d
commit ac8a6054b0
8 files changed
+120 -3

No files matched your search

@@ -0,0 +1,18 @@
import ApplicationSerializer from './application';
export default class AuthMethodSerializer extends ApplicationSerializer {
/**
* Sorts the array in order of "primary" such that the primary method appears
* first. The "natural" order of auth methods places primary first.
*
* @override
* @return {object}
*/
normalizeArrayResponse() {
const normalized = super.normalizeArrayResponse(...arguments);
normalized.data = normalized.data.sort((a) =>
a.attributes.primary ? -1 : 1
);
return normalized;
}
}