Last Login Status Display
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
LastLoginDisplayis an item ofSetting/interfacein 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/usercontainspreviousLoginDate. 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 nopreviousLoginDate(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 |
|---|---|
|
NEW. Presentational component |
|
CHANGE. Selects the flag and the view of the panel, renders |
|
CHANGE. Declare and export |
|
CHANGE. Three optional fields on |
|
CHANGE. Add |
|
CHANGE. Add the slice for the previous login record (see Storage of the record). |
|
CHANGE. Add the selector that returns the view of the panel. |
|
CHANGE. Add |
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.
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:
-
previousLoginDateandpreviousFailedAttemptsdescribe the attempt before the current session, not the current login. -
The fields are the same on every
User/usercall 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
previousLoginDateIsoandpreviousFailedAttempts, 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. |
|
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 |
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
previousFailedAttemptsis 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.