Last Login Status Display

Field Value

Jira

DEV-3023

Backend

DEV-3341

The same feature in the CPE Admin application

DEV-3022

Portals

Management Console and Support Center

Goal

Show the previous login attempt of the current user (date and time, and "Logged in" or "Failed") in a collapsible panel of the side bar. The panel is controlled by the interface flag LastLoginDisplay.

Requirements

  • The flag LastLoginDisplay is an item of Setting/interface in the Authentication section. There is one flag per portal. An administrator changes it without a deployment.

  • The panel sits in the shared side bar, between the application title block and the user block.

  • The panel is shown only when the flag is on, the side bar is expanded, and the response of User/user contains previousLoginDate. Otherwise there is no panel and no placeholder, and the side bar looks as it does today. The UI does not depend on the login method: a user for whom the backend sends no previousLoginDate (for example an SSO user) sees no panel.

  • The panel shows the date and time, and the status. If the number of failed attempts is above zero, the status is "Failed". Otherwise (zero, null or absent) the status is "Logged in".

  • The panel shows data of the current user only.

  • The panel is a collapsible accordion, expanded by default. The state is not persisted.

  • There is no new HTTP call.

  • Deviation from the FRD: Alerts is a separate tab in the Angular portals, not a side-bar panel, so the mockup state 1a ("stacked below Alerts") does not apply. States 1b and 1c are used.

The backend formats previousLoginDate with the date and time format of the user. The UI shows the string as it is, without time-zone conversion.

Affected components

File Change

projects/ft-common/components/src/side-bar/last-login/last-login.component.{ts,html,scss}

NEW. Presentational component ft-common-last-login with OnPush change detection, built on ft-common-accordion. One input: view: ILastLoginView.

projects/ft-common/components/src/side-bar/side-bar.component.{ts,html,scss}

CHANGE. Selects the flag and the view of the panel, renders ft-common-last-login between .info-application and .info-user, moves the menu to a flow layout (see Layout).

projects/ft-common/components/component.module.ts

CHANGE. Declare and export LastLoginComponent.

projects/ft-common/models/src/user.model.ts

CHANGE. Three optional fields on User and the ILastLoginView interface.

projects/ft-common/models/src/interfaces/settings-interface.interface.ts

CHANGE. Add SettingsInterfaceIdEnum.lastLoginDisplay = 'LastLoginDisplay'.

projects/ft-common/store/src/reducers/settings/user.reducer.ts

CHANGE. Add the slice for the previous login record (see Storage of the record).

projects/ft-common/store/src/selectors/settings/user.selectors.ts

CHANGE. Add the selector that returns the view of the panel.

projects/management-console/src/assets/i18n/en.json, projects/support-center/src/assets/i18n/en.json, projects/support-center/src/assets/i18n/he.json

CHANGE. Add labels.last-login and labels.logged-in. Reuse labels.failed (add it to the Support Center he.json, which does not have it). Management Console has no he.json.

Design

Storage of the record

User/user for the current user is called on login, at dashboard init and on every periodic refresh of the current user, and the current user in the store is replaced each time (also by the edit-user response). The panel therefore reads the record from its own slice of the user store, not from the current user. The slice holds the previous login date, the number of failed attempts and the id of the user they belong to.

  • The first record received after login is stored and then kept for the session. Later responses for the same user do not change it.

  • A response for a different user replaces the record, or clears it if that user has none.

  • Login clears the record, so a new login always starts empty.

  • The record is cleared on logout. It is not lost when User Management closes, although that cleanup resets most of the user store.

  • Responses for other users and edit responses never change the record.

A selector returns the ready view of the panel (the date and a failed flag) or nothing, so the template calls no function.

Flag

The side bar reads the flag from the interface settings. The flag is off by default (the default is set by the backend). The panel is shown only when the flag is on. If the setting is missing in the response, the flag is treated as off.

Layout

The menu is placed with a fixed offset, which hard-codes the height of the two blocks above it. The height of the new panel varies, so the menu moves to a flow layout and takes the remaining height. With the panel absent, the side bar must look as it does today.

Data model

// user.model.ts, additions to class User (all optional; absent on backends without DEV-3341)
previousLoginDate?: string | null;
previousLoginDateIso?: string | null;    // not used by the UI
previousFailedAttempts?: number | null;

// user.model.ts, view of the panel
export interface ILastLoginView { readonly date: string; readonly isFailed: boolean; }

Contract with the backend

DEV-3341 owns this contract. The text below quotes it.

POST User/user   body: { id: null }            (current user)
response, added fields:
  previousLoginDate        string | null   date and time of the previous login attempt; null on the first login
  previousLoginDateIso     string          ISO-8601 of the same instant (not used by the UI)
  previousFailedAttempts   number          failed attempts before the current login

POST Setting/interface   (per clientType, one item per portal)
  item { id: "LastLoginDisplay", valueType: "BOOLEAN", default false, section Authentication,
         description "Show or hide last login info. Default value is 'false'." }
  (the same name, default and description as the same setting in the CPE Admin application, DEV-3022)

The UI relies on the following from DEV-3341:

  • previousLoginDate and previousFailedAttempts describe the attempt before the current session, not the current login.

  • The fields are the same on every User/user call within one session, including after a page reload.

  • The fields are filled only for the caller, never when an administrator fetches another user by id.

  • The date format, the nullability of previousLoginDateIso and previousFailedAttempts, and the boolean type of the flag value are confirmed.

UX

State Side bar

Flag off or missing

No panel and no placeholder. The layout is identical to today.

previousLoginDate absent, null or empty

No panel.

Side bar collapsed

No panel. The panel is shown again when the side bar is expanded.

Previous attempt succeeded (zero, null or no failed attempts)

Header with the title "Last login" and a chevron. Line 1 shows the date and time. Line 2 shows "Logged in".

Previous attempt failed (failed attempts above zero)

Same as above. Line 2 shows "Failed" in --status-negative.

The panel uses theme variables only (--bg-alt-03, --fg-main, --fg-alt-01, --status-negative), in both themes. The status text is bold. The panel does not use the yellow background and the icon of the mockup: it keeps the look of the other side-bar elements.

The texts "Last login", "Logged in" and "Failed" are i18n keys. The Hebrew texts for Support Center must be checked by a native speaker before release.

Risks

  • The backend does not deliver the expectations above: the panel shows wrong data, or data of another user.

  • The backend may deliver only the last successful login. Then previousFailedAttempts is always 0 and "Failed" never appears. The UI needs no change.

The UI is safe to ship before DEV-3341: all new fields are optional, and if the flag is missing there is no panel.

Appendix A: Design concept

Design concept of the Last login panel

The design concept shows states 1a, 1b and 1c. This design uses states 1b and 1c.