Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Créer le composant des autres moyens de connexion/inscription (PIX-14159) #10275

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ const serialize = function (oidcIdentityProviders) {
id: oidcIdentityProvider.slug,
code: oidcIdentityProvider.code,
organizationName: oidcIdentityProvider.organizationName,
slug: oidcIdentityProvider.slug,
shouldCloseSession: oidcIdentityProvider.shouldCloseSession,
source: oidcIdentityProvider.source,
};
},
attributes: ['code', 'organizationName', 'shouldCloseSession', 'source'],
attributes: ['code', 'organizationName', 'slug', 'shouldCloseSession', 'source'],
}).serialize(oidcIdentityProviders);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('Acceptance | Identity Access Management | Route | Admin | oidc-provide
attributes: {
code: 'OIDC_EXAMPLE_NET',
'organization-name': 'OIDC Example',
slug: 'oidc-example-net',
'should-close-session': true,
source: 'oidcexamplenet',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('Acceptance | Identity Access Management | Application | Route | oidc-p
attributes: {
code: 'OIDC_EXAMPLE_NET',
'organization-name': 'OIDC Example',
slug: 'oidc-example-net',
'should-close-session': true,
source: 'oidcexamplenet',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ describe('Unit | Identity Access Management | Application | Controller | Admin |
attributes: {
code: 'LIMONADE_OIDC_PROVIDER',
'organization-name': 'Limonade OIDC Provider',
slug: 'limonade-oidc-provider',
'should-close-session': false,
source: 'limonade_oidc_provider',
},
Expand All @@ -142,6 +143,7 @@ describe('Unit | Identity Access Management | Application | Controller | Admin |
attributes: {
code: 'KOMBUCHA_OIDC_PROVIDER',
'organization-name': 'Kombucha OIDC Provider',
slug: 'kombucha-oidc-provider',
'should-close-session': true,
source: 'kombucha_oidc_provider',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ describe('Unit | Identity Access Management | Application | Controller | oidc-pr
code: 'SOME_OIDC_PROVIDER',
source: 'some_oidc_provider',
'organization-name': 'Some OIDC Provider',
slug: 'some-oidc-provider',
'should-close-session': false,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('Unit | Identity Access Management | Infrastructure | Serializer | JSON
attributes: {
code: 'OIDC_PARTNER',
'organization-name': 'Partenaire OIDC',
slug: 'oidc-partner',
'should-close-session': true,
source: 'oidc-external',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { t } from 'ember-intl';

export default class OtherAuthenticationProviders extends Component {
@service oidcIdentityProviders;
@service router;

<template>
<section class="authentication-other-authentication-providers-section">
<h2 class="authentication-other-authentication-providers-section__heading">
{{#if @isForSignup}}
{{t "components.authentication.other-authentication-providers.signup-heading"}}
{{else}}
{{t "components.authentication.other-authentication-providers.login-heading"}}
{{/if}}
</h2>

{{#if this.oidcIdentityProviders.featuredIdentityProvider}}
<PixButtonLink
@route="authentication.login-oidc"
@model="{{this.oidcIdentityProviders.featuredIdentityProvider.slug}}"
@variant="secondary"
@size="large"
class="authentication-other-authentication-providers-section__button-link"
>
<img
src="/images/logo/{{this.oidcIdentityProviders.featuredIdentityProvider.slug}}-connect-logo.svg"
alt=""
class="authentication-other-authentication-providers-section__featured-identity-provider-logo"
/>

{{t
"components.authentication.other-authentication-providers.continue-with-featured-identity-provider-link"
featuredIdentityProvider=this.oidcIdentityProviders.featuredIdentityProvider.organizationName
}}</PixButtonLink>
{{/if}}

{{#if this.oidcIdentityProviders.hasOtherIdentityProviders}}
<PixButtonLink
@route="authentication.sso-selection"
@variant="secondary"
@size="large"
class="authentication-other-authentication-providers-section__button-link"
>
{{t "components.authentication.other-authentication-providers.select-another-organization-link"}}

<span class="authentication-other-authentication-providers-section__chevron-right">
{{! template-lint-disable "no-bare-strings" }}
&#x3009;
</span>
</PixButtonLink>
{{/if}}
</section>
</template>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.authentication-other-authentication-providers-section {
display: flex;
flex-direction: column;
gap: var(--pix-spacing-4x);

&__heading {
display: flex;
gap: var(--pix-spacing-6x);
margin-top: var(--pix-spacing-10x);
margin-bottom: var(--pix-spacing-10x);
color: var(--pix-neutral-500);
}

&__heading::before,
&__heading::after {
flex: 1 1;
margin: auto;
border-bottom: 1px solid var(--pix-neutral-100);
content: "";
}

&__button-link {
border: 1px solid;
}

&__featured-identity-provider-logo {
width: var(--pix-spacing-6x);
margin-right: var(--pix-spacing-4x);
}

// TODO: Use @iconAfter="chevronRight" when possible
&__chevron-right {
padding-left: var(--pix-spacing-6x);
font-weight: 1000;
}
}
1 change: 1 addition & 0 deletions mon-pix/app/models/oidc-identity-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Model, { attr } from '@ember-data/model';
export default class OidcIdentityProvider extends Model {
@attr() code;
@attr() organizationName;
@attr() slug;
@attr() shouldCloseSession;
@attr() source;
}
26 changes: 26 additions & 0 deletions mon-pix/app/services/oidc-identity-providers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import Service, { inject as service } from '@ember/service';
import isEmpty from 'lodash/isEmpty';

// TODO: Manage this through the API
const FR_FEATURED_IDENTITY_PROVIDER_CODE = 'POLE_EMPLOI';
const ORG_FEATURED_IDENTITY_PROVIDER_CODE = 'FWB';
const FEATURED_IDENTITY_PROVIDER_CODES = [FR_FEATURED_IDENTITY_PROVIDER_CODE, ORG_FEATURED_IDENTITY_PROVIDER_CODE];

export default class OidcIdentityProviders extends Service {
@service store;
@service currentDomain;

get list() {
return this.store.peekAll('oidc-identity-provider');
Expand All @@ -15,6 +21,26 @@ export default class OidcIdentityProviders extends Service {
.map((provider) => provider.organizationName);
}

// TODO: Manage this through the API
get featuredIdentityProvider() {
return this.list.find((identityProvider) => {
const featuredIdentityProviderCode = this.currentDomain.isFranceDomain
? FR_FEATURED_IDENTITY_PROVIDER_CODE
: ORG_FEATURED_IDENTITY_PROVIDER_CODE;

return identityProvider.code === featuredIdentityProviderCode;
});
}

// TODO: Manage this through the API
get hasOtherIdentityProviders() {
if (!this.currentDomain.isFranceDomain) {
return false;
}

return this.list.some((identityProvider) => !FEATURED_IDENTITY_PROVIDER_CODES.includes(identityProvider.code));
}

isFwbActivated() {
const identityProviderSlug = 'fwb';
const oidcIdentityProviders = this.list.filter((provider) => provider.id === identityProviderSlug);
Expand Down
1 change: 1 addition & 0 deletions mon-pix/app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ of an adaptative/mobile-first approach — refactoring is welcome here */
@import 'authentication/oidc-provider-selector';
@import 'authentication/signin-form';
@import 'authentication/sso-selection-form';
@import 'authentication/other-authentication-providers';
@import 'authentication/password-input/password-checklist';
@import 'authentication/password-input/password-rule';

Expand Down
1 change: 1 addition & 0 deletions mon-pix/app/templates/authentication/login.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<:content>
<h1 class="pix-title-m">{{t "pages.sign-in.first-title"}}</h1>
<Authentication::SigninForm />
<Authentication::OtherAuthenticationProviders />
</:content>
</AuthenticationLayout>
{{else}}
Expand Down
1 change: 1 addition & 0 deletions mon-pix/mirage/routes/authentication/oidc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function (config) {
attributes: {
code: 'OIDC_PARTNER',
'organization-name': 'Partenaire OIDC',
slug: 'partenaire-oidc',
'should-close-session': false,
source: 'oidc-externe',
},
Expand Down
12 changes: 12 additions & 0 deletions mon-pix/public/images/logo/pole-emploi-connect-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module('Integration | Component | authentication | login-or-register-oidc', func
id: 'oidc-partner',
code: 'OIDC_PARTNER',
organizationName: 'Partenaire OIDC',
slug: 'partenaire-oidc',
shouldCloseSession: false,
source: 'oidc-externe',
};
Expand Down
Loading
Loading