@@ -5,6 +5,7 @@ import { action } from '@ember/object';
55import { service } from ' @ember/service' ;
66import Component from ' @glimmer/component' ;
77import { tracked } from ' @glimmer/tracking' ;
8+ import dayjs from ' dayjs' ;
89import dayjsFormat from ' ember-dayjs/helpers/dayjs-format' ;
910import { t } from ' ember-intl' ;
1011
@@ -15,6 +16,7 @@ import ReassignOidcAuthenticationMethodModal from './reassign-oidc-authenticatio
1516export default class AuthenticationMethod extends Component {
1617 @service pixToast;
1718 @service accessControl;
19+ @service intl;
1820 @service oidcIdentityProviders;
1921
2022 @tracked showAddAuthenticationMethodModal = false ;
@@ -87,12 +89,15 @@ export default class AuthenticationMethod extends Component {
8789 get emailAuthenticationMethod () {
8890 return { code: ' EMAIL' , name: ' Adresse e-mail' };
8991 }
92+
9093 get userNameAuthenticationMethod () {
9194 return { code: ' USERNAME' , name: ' Identifiant' };
9295 }
96+
9397 get garAuthenticationMethod () {
9498 return { code: ' GAR' , name: ' Médiacentre' };
9599 }
100+
96101 get userOidcAuthenticationMethods () {
97102 return this .oidcIdentityProviders .list .map ((oidcIdentityProvider ) => {
98103 const userHasThisOidcAuthenticationMethod = this .authenticationMethods .any (
@@ -110,6 +115,29 @@ export default class AuthenticationMethod extends Component {
110115 });
111116 }
112117
118+ get pixLastLoggedAtAuthenticationMethod () {
119+ const method = this .authenticationMethods .find ((method ) => method .identityProvider === ' PIX' );
120+ return method ? this ._displayAuthenticationMethodDate (method .lastLoggedAt ) : null ;
121+ }
122+
123+ get garLastLoggedAtAuthenticationMethod () {
124+ const method = this .authenticationMethods .find ((method ) => method .identityProvider === ' GAR' );
125+ return method ? this ._displayAuthenticationMethodDate (method .lastLoggedAt ) : null ;
126+ }
127+
128+ _displayAuthenticationMethodDate (date ) {
129+ if (! date) return null ;
130+ return this .intl .t (' components.users.user-detail-personal-information.authentication-method.last-logged-at' , {
131+ date: dayjs (date).format (' DD/MM/YYYY' ),
132+ });
133+ }
134+
135+ @action
136+ oidcLastLoggedAtAuthenticationMethod (oidc ) {
137+ const method = this .authenticationMethods .find ((method ) => method .identityProvider === oidc .code );
138+ return method ? this ._displayAuthenticationMethodDate (method .lastLoggedAt ) : null ;
139+ }
140+
113141 @action
114142 onChangeNewEmail (event ) {
115143 this .newEmail = event .target .value ;
@@ -244,6 +272,7 @@ export default class AuthenticationMethod extends Component {
244272 />
245273 {{/if }}
246274 </td >
275+ <td >{{this .pixLastLoggedAtAuthenticationMethod }} </td >
247276 <td >
248277 {{#if this . accessControl.hasAccessToUsersActionsScope }}
249278 {{#if this . isAllowedToRemoveEmailAuthenticationMethod }}
@@ -284,6 +313,7 @@ export default class AuthenticationMethod extends Component {
284313 />
285314 {{/if }}
286315 </td >
316+ <td >{{this .pixLastLoggedAtAuthenticationMethod }} </td >
287317 <td >
288318 {{#if this . accessControl.hasAccessToUsersActionsScope }}
289319 {{#if this . isAllowedToRemoveUsernameAuthenticationMethod }}
@@ -319,6 +349,7 @@ export default class AuthenticationMethod extends Component {
319349 />
320350 {{/if }}
321351 </td >
352+ <td >{{this .garLastLoggedAtAuthenticationMethod }} </td >
322353 <td class =" authentication-method-table__actions-column" >
323354 {{#if this . accessControl.hasAccessToUsersActionsScope }}
324355 <div >
@@ -361,6 +392,7 @@ export default class AuthenticationMethod extends Component {
361392 />
362393 {{/if }}
363394 </td >
395+ <td >{{this .oidcLastLoggedAtAuthenticationMethod userOidcAuthenticationMethod }} </td >
364396 <td class =" authentication-method-table__actions-column" >
365397 {{#if this . accessControl.hasAccessToUsersActionsScope }}
366398 <div >
0 commit comments