open-vault/ui/app/models/role-jwt.js
Jordan Reimer 52fe56ec87
Eslint prefer-const (#17864)
* adds prefer-const to eslint config and runs fixer

* reverts unintended change
2022-11-09 15:15:31 -08:00

32 lines
904 B
JavaScript

import Model, { attr } from '@ember-data/model';
import { computed } from '@ember/object';
import parseURL from 'core/utils/parse-url';
const DOMAIN_STRINGS = {
github: 'GitHub',
gitlab: 'GitLab',
google: 'Google',
ping: 'Ping',
okta: 'Okta',
auth0: 'Auth0',
};
const PROVIDER_WITH_LOGO = ['GitLab', 'Google', 'Auth0'];
export { DOMAIN_STRINGS, PROVIDER_WITH_LOGO };
export default Model.extend({
authUrl: attr('string'),
providerName: computed('authUrl', function () {
const { hostname } = parseURL(this.authUrl);
const firstMatch = Object.keys(DOMAIN_STRINGS).find((name) => hostname.includes(name));
return DOMAIN_STRINGS[firstMatch] || null;
}),
providerButtonComponent: computed('providerName', function () {
const { providerName } = this;
return PROVIDER_WITH_LOGO.includes(providerName) ? `auth-button-${providerName.toLowerCase()}` : null;
}),
});