Skip to content

Commit f8f6c5d

Browse files
committed
feat(admin): Add a yes no info about user sso
1 parent b97cdcd commit f8f6c5d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

Diff for: admin/app/components/users/user-overview.gjs

+16
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ export default class UserOverview extends Component {
2727
@service pixToast;
2828
@service references;
2929
@service store;
30+
@service oidcIdentityProviders;
3031

3132
@tracked displayAnonymizeModal = false;
3233
@tracked isEditionMode = false;
34+
@tracked authenticationMethods = [];
3335

3436
languages = this.references.availableLanguages;
3537
locales = this.references.availableLocales;
@@ -39,6 +41,9 @@ export default class UserOverview extends Component {
3941
constructor() {
4042
super(...arguments);
4143
this.form = this.store.createRecord('user-form');
44+
Promise.resolve(this.args.user.authenticationMethods).then((authenticationMethods) => {
45+
this.authenticationMethods = authenticationMethods;
46+
});
4247
}
4348

4449
get externalURL() {
@@ -86,6 +91,14 @@ export default class UserOverview extends Component {
8691
return this.args.user.username ? null : 'obligatoire';
8792
}
8893

94+
get useOidcAuthentication() {
95+
const oidcProvidersCodes = this.oidcIdentityProviders.list.map((provider) => provider.code);
96+
const userHasThisOidcAuthenticationMethod = this.authenticationMethods.any((authenticationMethod) =>
97+
oidcProvidersCodes.includes(authenticationMethod.identityProvider),
98+
);
99+
return userHasThisOidcAuthenticationMethod ? 'Oui' : 'Non';
100+
}
101+
89102
_initForm() {
90103
this.form.firstName = this.args.user.firstName;
91104
this.form.lastName = this.args.user.lastName;
@@ -331,6 +344,9 @@ export default class UserOverview extends Component {
331344
{{/if}}
332345
</span>
333346
</li>
347+
<li class="user-detail-personal-information-section__user-informations flex space-between gap-4x">
348+
<span>SSO : {{this.useOidcAuthentication}}</span>
349+
</li>
334350
</ul>
335351

336352
<ul class="user-detail-personal-information-section__infogroup">

Diff for: admin/tests/integration/components/users/user-overview-test.gjs

+22
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,20 @@ module('Integration | Component | users | user-overview', function (hooks) {
1717
hasAccessToUsersActionsScope = true;
1818
}
1919

20+
class OidcIdentityProvidersStub extends Service {
21+
get list() {
22+
return [
23+
{
24+
code: 'SUNLIGHT_NAVIGATIONS',
25+
organizationName: 'Sunlight Navigations',
26+
},
27+
];
28+
}
29+
}
30+
2031
hooks.beforeEach(function () {
2132
this.owner.register('service:access-control', AccessControlStub);
33+
this.owner.register('service:oidcIdentityProviders', OidcIdentityProvidersStub);
2234
});
2335

2436
module('when the admin look at user details', function () {
@@ -37,6 +49,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
3749
hasBeenAnonymised: true,
3850
hasBeenAnonymisedBy: 123,
3951
anonymisedByFullName: '(anonymised) (anonymised)',
52+
authenticationMethods: [],
4053
});
4154

4255
// when
@@ -63,6 +76,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
6376
hasBeenAnonymised: true,
6477
hasBeenAnonymisedBy: 456,
6578
anonymisedByFullName: fullName,
79+
authenticationMethods: [],
6680
});
6781

6882
// when
@@ -88,6 +102,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
88102
lastName: 'Harry',
89103
email: 'john.harry@example.net',
90104
username: 'john.harry0102',
105+
authenticationMethods: [],
91106
};
92107

93108
// when
@@ -108,6 +123,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
108123
lang: 'fr',
109124
locale: 'fr-FR',
110125
createdAt: new Date('2021-12-10'),
126+
authenticationMethods: [],
111127
});
112128

113129
// when
@@ -118,6 +134,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
118134
assert.dom(screen.getByText(`Nom : ${user.lastName}`)).exists();
119135
assert.dom(screen.getByText(`Adresse e-mail : ${user.email}`)).exists();
120136
assert.dom(screen.getByText(`Identifiant : ${user.username}`)).exists();
137+
assert.dom(screen.getByText("SSO : Non")).exists()
121138
assert.dom(screen.getByText('Langue : fr')).exists();
122139
assert.dom(screen.getByText('Locale : fr-FR')).exists();
123140
assert.dom(screen.getByText('Date de création : 10/12/2021')).exists();
@@ -140,6 +157,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
140157
username: 'kingofthenorth',
141158
lang: expected.lang,
142159
locale: expected.locale,
160+
authenticationMethods: [],
143161
});
144162

145163
// when
@@ -169,6 +187,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
169187
lang: 'fr',
170188
locale: 'fr-FR',
171189
createdAt: new Date('2021-12-10'),
190+
authenticationMethods: [],
172191
});
173192

174193
// when
@@ -195,6 +214,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
195214
lang: 'fr',
196215
locale: 'fr-FR',
197216
createdAt: new Date('2021-12-10'),
217+
authenticationMethods: [],
198218
});
199219

200220
// when
@@ -221,6 +241,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
221241
lang: 'fr',
222242
locale: 'fr-FR',
223243
createdAt: new Date('2021-12-10'),
244+
authenticationMethods: [],
224245
});
225246

226247
// when
@@ -247,6 +268,7 @@ module('Integration | Component | users | user-overview', function (hooks) {
247268
lang: 'fr',
248269
locale: 'fr-FR',
249270
createdAt: new Date('2021-12-10'),
271+
authenticationMethods: [],
250272
});
251273

252274
// when

0 commit comments

Comments
 (0)