2019-02-14 15:39:19 +00:00
|
|
|
import DS from 'ember-data';
|
|
|
|
import { computed } from '@ember/object';
|
2019-07-02 22:41:23 +00:00
|
|
|
import parseURL from 'core/utils/parse-url';
|
2019-02-14 15:39:19 +00:00
|
|
|
const { attr } = DS;
|
|
|
|
|
|
|
|
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 DS.Model.extend({
|
|
|
|
authUrl: attr('string'),
|
|
|
|
|
|
|
|
providerName: computed('authUrl', function() {
|
|
|
|
let { hostname } = parseURL(this.authUrl);
|
|
|
|
let firstMatch = Object.keys(DOMAIN_STRINGS).find(name => hostname.includes(name));
|
|
|
|
return DOMAIN_STRINGS[firstMatch] || null;
|
|
|
|
}),
|
|
|
|
|
|
|
|
providerButtonComponent: computed('providerName', function() {
|
|
|
|
let { providerName } = this;
|
|
|
|
return PROVIDER_WITH_LOGO.includes(providerName) ? `auth-button-${providerName.toLowerCase()}` : null;
|
|
|
|
}),
|
|
|
|
});
|