pict-section-login 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # Pict Section Login
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+
5
+ ---
6
+
7
+ A drop-in login section for Pict applications. Renders a styled login form, calls out to [orator-authentication](https://github.com/stevenvelozo/orator-authentication) (or any custom backend) for sign-in / sign-out / session-check, stores the resulting session on the Pict AppData tree, and exposes override hooks so you can chain navigation, route resolution, or any other post-auth behavior.
8
+
9
+ ## Features
10
+
11
+ - **Drop-In View** -- Extends `pict-view`; register with `pict.addView(...)` and call `render()` to get a complete login form
12
+ - **Orator-Authentication Ready** -- Default endpoints match the standard `orator-authentication` routes; works out of the box
13
+ - **Custom Backend Friendly** -- Every endpoint is configurable, both POST (JSON body) and GET (URL-encoded credentials) are supported
14
+ - **Session Management** -- `login`, `logout`, and `checkSession` methods plus automatic check-on-load
15
+ - **OAuth Provider Support** -- Optional OAuth button row populated from `/OAuth/Providers` and redirected through `/OAuth/Begin`
16
+ - **AppData Integration** -- Session data is written to a configurable Pict manifest address (default `AppData.Session`)
17
+ - **Override Hooks** -- `onLoginSuccess`, `onLoginFailed`, `onLogout`, `onSessionChecked` for post-auth navigation and app state updates
18
+ - **Router Friendly** -- Designed to cooperate with [pict-router](https://github.com/stevenvelozo/pict-router) for route-guarded navigation and post-login redirects
19
+ - **Styled Out of the Box** -- Embedded CSS design system renders a polished card with no extra styling required
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install pict-section-login
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```javascript
30
+ const libPict = require('pict');
31
+ const libPictSectionLogin = require('pict-section-login');
32
+
33
+ class MyLoginView extends libPictSectionLogin
34
+ {
35
+ onLoginSuccess(pSessionData)
36
+ {
37
+ this.log.info('Logged in as', pSessionData?.UserRecord?.LoginID);
38
+ // e.g. this.pict.PictApplication.showProtectedApp();
39
+ }
40
+ }
41
+
42
+ const _Pict = new libPict();
43
+ _Pict.addView(
44
+ 'MyLogin',
45
+ {
46
+ "ViewIdentifier": "MyLogin",
47
+ "TargetElementAddress": "#Pict-Login-Container"
48
+ },
49
+ MyLoginView);
50
+
51
+ _Pict.views.MyLogin.render();
52
+ ```
53
+
54
+ Drop a mount point into your page:
55
+
56
+ ```html
57
+ <div id="Pict-Login-Container"></div>
58
+ ```
59
+
60
+ That's the whole thing for a default orator-authentication wiring. See [docs/quickstart.md](docs/quickstart.md) for custom backends, OAuth, hooks, and AppData access.
61
+
62
+ ## Configuration Overview
63
+
64
+ | Key | Default | Purpose |
65
+ |---|---|---|
66
+ | `LoginEndpoint` | `/1.0/Authenticate` | Endpoint to POST credentials to |
67
+ | `LoginMethod` | `POST` | `POST` (JSON body) or `GET` (URL-encoded) |
68
+ | `LogoutEndpoint` | `/1.0/Deauthenticate` | Endpoint to end the session |
69
+ | `CheckSessionEndpoint` | `/1.0/CheckSession` | Endpoint to validate an existing session |
70
+ | `OAuthProvidersEndpoint` | `/1.0/OAuth/Providers` | List of available OAuth providers |
71
+ | `OAuthBeginEndpoint` | `/1.0/OAuth/Begin` | OAuth redirect prefix |
72
+ | `CheckSessionOnLoad` | `true` | Auto-call `checkSession` on first render |
73
+ | `ShowOAuthProviders` | `false` | Render OAuth buttons alongside the form |
74
+ | `SessionDataAddress` | `AppData.Session` | Manifest address to store session data |
75
+ | `TargetElementAddress` | `#Pict-Login-Container` | CSS selector for the mount point |
76
+
77
+ See [docs/configuration.md](docs/configuration.md) for the full reference.
78
+
79
+ ## Public API
80
+
81
+ | Method | Purpose |
82
+ |---|---|
83
+ | `login(pUsername, pPassword, fCallback)` | Authenticate with credentials |
84
+ | `logout(fCallback)` | End the current session |
85
+ | `checkSession(fCallback)` | Validate an existing session (e.g. from a cookie) |
86
+ | `loadOAuthProviders(fCallback)` | Fetch and render OAuth provider buttons |
87
+ | `onLoginSuccess(pSessionData)` | Override hook fired after successful login |
88
+ | `onLoginFailed(pError)` | Override hook fired after failed login |
89
+ | `onLogout()` | Override hook fired after logout |
90
+ | `onSessionChecked(pSessionData)` | Override hook fired after a session check |
91
+
92
+ See [docs/api-reference.md](docs/api-reference.md) and [docs/code-snippets.md](docs/code-snippets.md) for complete details and runnable examples.
93
+
94
+ ## Router Integration
95
+
96
+ `pict-section-login` pairs naturally with [pict-router](https://github.com/stevenvelozo/pict-router): register your routes with `SkipRouteResolveOnAdd: true`, call `checkSession()` before resolving, and implement a `PendingRoute` redirect in `onLoginSuccess`. See [docs/router-integration.md](docs/router-integration.md) for the full pattern, including route guards and post-login redirects.
97
+
98
+ ## Documentation
99
+
100
+ - [Overview](docs/README.md)
101
+ - [Quick Start](docs/quickstart.md)
102
+ - [Architecture](docs/architecture.md)
103
+ - [Configuration](docs/configuration.md)
104
+ - [API Reference](docs/api-reference.md)
105
+ - [Code Snippets](docs/code-snippets.md)
106
+ - [Embedding Guide](docs/embedding-guide.md)
107
+ - [Router Integration](docs/router-integration.md)
108
+ - [Templates & Styling](docs/templates-and-styling.md)
109
+
110
+ ## Example Applications
111
+
112
+ - [`example_applications/orator_login`](example_applications/orator_login) -- minimal orator-authentication wiring
113
+ - [`example_applications/custom_login`](example_applications/custom_login) -- custom endpoints + override hooks
114
+ - [`example_applications/oauth_login`](example_applications/oauth_login) -- OAuth provider list integration
115
+ - [`example_applications/harness_app`](example_applications/harness_app) -- full integration: login + pict-router + protected views + top bar
116
+
117
+ ## Testing
118
+
119
+ ```bash
120
+ npm test
121
+ npm run test-browser # Puppeteer headless browser tests
122
+ npm run coverage
123
+ ```
124
+
125
+ ## Related Packages
126
+
127
+ - [pict](https://github.com/stevenvelozo/pict) -- MVC application framework
128
+ - [pict-view](https://github.com/stevenvelozo/pict-view) -- View base class
129
+ - [pict-router](https://github.com/stevenvelozo/pict-router) -- Hash-based router that pairs with this module
130
+ - [pict-application](https://github.com/stevenvelozo/pict-application) -- Application host and lifecycle
131
+ - [orator-authentication](https://github.com/stevenvelozo/orator-authentication) -- Default backend
132
+ - [fable](https://github.com/stevenvelozo/fable) -- Core service ecosystem
133
+
134
+ ## License
135
+
136
+ MIT
137
+
138
+ ## Contributing
139
+
140
+ Pull requests welcome. See the [Retold Contributing Guide](https://github.com/stevenvelozo/retold/blob/main/docs/contributing.md) for the code of conduct, contribution process, and testing requirements.
package/docs/.nojekyll ADDED
File without changes
package/docs/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Pict Section Login
2
+
3
+ > A drop-in login section for Pict applications
4
+
5
+ Pict Section Login is a `pict-view` subclass that renders a styled authentication form, talks to a REST backend (the default endpoints match [orator-authentication](https://github.com/stevenvelozo/orator-authentication), but everything is configurable), stores the resulting session on the Pict AppData tree, and exposes override hooks so you can chain navigation, route resolution, or any other post-auth behavior.
6
+
7
+ The view ships with:
8
+
9
+ - A container template with a styled card, an error strip, a form area, an OAuth area, and a status area
10
+ - A login form template (username + password + submit)
11
+ - A logged-in status bar with user name, user id, and logout button
12
+ - An OAuth providers row that fetches and renders provider buttons
13
+ - An error template for inline error display
14
+ - An embedded CSS design system covering all of the above
15
+
16
+ Everything is replaceable via the `Templates` array in the configuration, and the entire visual layer can be restyled by overriding the `CSS` block or simply applying your own rules on top of the `.pict-login-*` classes.
17
+
18
+ ## Features
19
+
20
+ - **Drop-In View** -- Extends `pict-view`; register via `pict.addView(...)` and call `render()`
21
+ - **Orator-Authentication Ready** -- Default endpoints match the standard orator-authentication routes
22
+ - **Custom Backend Friendly** -- `LoginEndpoint`, `LogoutEndpoint`, `CheckSessionEndpoint`, and OAuth endpoints are all configurable; POST (JSON body) and GET (URL-encoded) are both supported for login
23
+ - **Session Management** -- `login`, `logout`, and `checkSession` methods plus automatic check-on-load via `CheckSessionOnLoad`
24
+ - **OAuth Provider Support** -- `loadOAuthProviders()` fetches the provider list and renders buttons that redirect through `OAuthBeginEndpoint`
25
+ - **AppData Integration** -- Session data is written to a configurable Pict manifest address (default `AppData.Session`) so any template solver or view can read it
26
+ - **Override Hooks** -- `onLoginSuccess`, `onLoginFailed`, `onLogout`, `onSessionChecked` hooks let you chain navigation or app-level state changes
27
+ - **Router Friendly** -- Designed to cooperate with [pict-router](https://github.com/stevenvelozo/pict-router) for route-guarded navigation and post-login redirects
28
+ - **Styled Out of the Box** -- Embedded CSS design system renders a polished card with no extra styling required
29
+ - **No Token Handling** -- Assumes the backend uses secure HTTP-only cookies; the view never touches `localStorage` or `sessionStorage`
30
+
31
+ ## When to Use It
32
+
33
+ Reach for this view when your Pict application needs to:
34
+
35
+ - Show a login screen before any protected content is rendered
36
+ - Integrate with `orator-authentication` or any REST auth backend that exposes `authenticate` / `deauthenticate` / `checksession` semantics
37
+ - Display OAuth provider buttons alongside a traditional username/password form
38
+ - Protect routes via `pict-router` and redirect users to their intended page after signing in
39
+ - Provide a consistent session-aware status bar across an application shell
40
+
41
+ Skip it if your application needs a custom-designed login screen that does not resemble the built-in card layout -- you can still use the `login` / `logout` / `checkSession` methods directly from any view, but the rendering layer assumes the bundled templates.
42
+
43
+ ## Learn More
44
+
45
+ - [Quick Start](quickstart.md) -- Install, register, and render your first login form
46
+ - [Embedding Guide](embedding-guide.md) -- How to place the login inside an existing Pict application, including shell layouts and auth-gated rendering
47
+ - [Router Integration](router-integration.md) -- Full pattern for `pict-router` route guards, pending-route redirects, and post-login navigation
48
+ - [Templates & Styling](templates-and-styling.md) -- Override the container, form, status, OAuth, and error templates; customize the CSS design system
49
+ - [Architecture](architecture.md) -- Class hierarchy, state diagram, and request flow
50
+ - [Configuration](configuration.md) -- Every key in `default_configuration` with defaults and descriptions
51
+ - [API Reference](api-reference.md) -- Every public method, parameter, callback signature, and override hook
52
+ - [Code Snippets](code-snippets.md) -- A runnable snippet for each exposed function
@@ -0,0 +1,18 @@
1
+ {
2
+ "Hash": "pict-section-login",
3
+ "Name": "Pict Section Login",
4
+ "Tagline": "Pict login section for authentication UIs — works with orator-authentication or any custom backend",
5
+ "Palette": "mix",
6
+ "Icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\" width=\"96\" height=\"96\">\n\t\t<defs>\n\t\t\t<clipPath id=\"frame-pict-section-login-filled-light\">\n\t\t\t\t<path d=\"M 2 48\n\t\t\tC 2 18.0222416, 18.0222416 2, 48 2\n\t\t\tC 77.9777584 2, 94 18.0222416, 94 48\n\t\t\tC 94 77.9777584, 77.9777584 94, 48 94\n\t\t\tC 18.0222416 94, 2 77.9777584, 2 48 Z\"/>\n\t\t\t</clipPath>\n\t\t</defs>\n\t\t<path d=\"M 2 48\n\t\t\tC 2 18.0222416, 18.0222416 2, 48 2\n\t\t\tC 77.9777584 2, 94 18.0222416, 94 48\n\t\t\tC 94 77.9777584, 77.9777584 94, 48 94\n\t\t\tC 18.0222416 94, 2 77.9777584, 2 48 Z\" fill=\"#34b3ce\"/>\n\t\t<g clip-path=\"url(#frame-pict-section-login-filled-light)\"><circle cx=\"39\" cy=\"48\" r=\"30\" fill=\"#dd6f55\" opacity=\"0.85\"/>\n\t\t\t\t\t<circle cx=\"57\" cy=\"48\" r=\"30\" fill=\"rgba(255,255,255,0.32)\" opacity=\"0.95\"/></g>\n\t\t<text x=\"48\" y=\"50\" text-anchor=\"middle\" dominant-baseline=\"central\"\n\t\t\tfont-family=\"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\"\n\t\t\tfont-size=\"28\" font-weight=\"600\"\n\t\t\tfill=\"#ffffff\" letter-spacing=\"-1\">PSL</text>\n\t</svg>",
7
+ "IconType": "svg",
8
+ "Favicon": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\" width=\"96\" height=\"96\">\n\t\t<defs>\n\t\t\t<clipPath id=\"fav-pict-section-login-light\">\n\t\t\t\t<path d=\"M 2 48\n\t\t\tC 2 18.0222416, 18.0222416 2, 48 2\n\t\t\tC 77.9777584 2, 94 18.0222416, 94 48\n\t\t\tC 94 77.9777584, 77.9777584 94, 48 94\n\t\t\tC 18.0222416 94, 2 77.9777584, 2 48 Z\"/>\n\t\t\t</clipPath>\n\t\t</defs>\n\t\t<path d=\"M 2 48\n\t\t\tC 2 18.0222416, 18.0222416 2, 48 2\n\t\t\tC 77.9777584 2, 94 18.0222416, 94 48\n\t\t\tC 94 77.9777584, 77.9777584 94, 48 94\n\t\t\tC 18.0222416 94, 2 77.9777584, 2 48 Z\" fill=\"#34b3ce\"/>\n\t\t<g clip-path=\"url(#fav-pict-section-login-light)\"><circle cx=\"39\" cy=\"48\" r=\"34\" fill=\"#dd6f55\"/>\n\t\t\t\t\t<circle cx=\"57\" cy=\"48\" r=\"34\" fill=\"rgba(255,255,255,0.22)\"/></g>\n\t\t<text x=\"48\" y=\"50\" text-anchor=\"middle\" dominant-baseline=\"central\"\n\t\t\tfont-family=\"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\"\n\t\t\tfont-size=\"60\" font-weight=\"800\"\n\t\t\tfill=\"#ffffff\" letter-spacing=\"-1\">P</text>\n\t</svg>",
9
+ "FaviconDark": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 96 96\" width=\"96\" height=\"96\">\n\t\t<defs>\n\t\t\t<clipPath id=\"fav-pict-section-login-dark\">\n\t\t\t\t<path d=\"M 2 48\n\t\t\tC 2 18.0222416, 18.0222416 2, 48 2\n\t\t\tC 77.9777584 2, 94 18.0222416, 94 48\n\t\t\tC 94 77.9777584, 77.9777584 94, 48 94\n\t\t\tC 18.0222416 94, 2 77.9777584, 2 48 Z\"/>\n\t\t\t</clipPath>\n\t\t</defs>\n\t\t<path d=\"M 2 48\n\t\t\tC 2 18.0222416, 18.0222416 2, 48 2\n\t\t\tC 77.9777584 2, 94 18.0222416, 94 48\n\t\t\tC 94 77.9777584, 77.9777584 94, 48 94\n\t\t\tC 18.0222416 94, 2 77.9777584, 2 48 Z\" fill=\"#83ccdb\"/>\n\t\t<g clip-path=\"url(#fav-pict-section-login-dark)\"><circle cx=\"39\" cy=\"48\" r=\"34\" fill=\"#e9b2a5\"/>\n\t\t\t\t\t<circle cx=\"57\" cy=\"48\" r=\"34\" fill=\"rgba(255,255,255,0.22)\"/></g>\n\t\t<text x=\"48\" y=\"50\" text-anchor=\"middle\" dominant-baseline=\"central\"\n\t\t\tfont-family=\"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif\"\n\t\t\tfont-size=\"60\" font-weight=\"800\"\n\t\t\tfill=\"#101418\" letter-spacing=\"-1\">P</text>\n\t</svg>",
10
+ "Colors": {
11
+ "Primary": "#34b3ce",
12
+ "Secondary": "#dd6f55",
13
+ "PrimaryLight": "#34b3ce",
14
+ "PrimaryDark": "#83ccdb",
15
+ "SecondaryLight": "#dd6f55",
16
+ "SecondaryDark": "#e9b2a5"
17
+ }
18
+ }
package/docs/_cover.md ADDED
@@ -0,0 +1,19 @@
1
+ # Pict Section Login
2
+
3
+ > A drop-in login section for Pict applications
4
+
5
+ Register it as a Pict view, point it at your auth endpoints, and you get a styled login form, session check, logout, and OAuth button support in a single view class. Override four lifecycle hooks to wire it to your application state, and pair it with pict-router for route-guarded navigation.
6
+
7
+ - **Drop-In View** -- One `pict.addView(...)` call gives you a complete login form
8
+ - **Orator-Authentication Ready** -- Default endpoints match the standard routes
9
+ - **Custom Backend Friendly** -- Every endpoint is configurable; POST and GET both supported
10
+ - **Session Management** -- `login`, `logout`, and `checkSession` with AppData integration
11
+ - **OAuth Providers** -- Optional OAuth row populated from a providers endpoint
12
+ - **Override Hooks** -- Four clean hooks for post-auth navigation and state updates
13
+ - **Router Friendly** -- Designed to cooperate with pict-router for route guards and post-login redirects
14
+
15
+ [Overview](README.md)
16
+ [Quick Start](quickstart.md)
17
+ [Embedding Guide](embedding-guide.md)
18
+ [Router Integration](router-integration.md)
19
+ [GitHub](https://github.com/stevenvelozo/pict-section-login)
@@ -0,0 +1,26 @@
1
+ - Getting Started
2
+
3
+ - [Overview](README.md)
4
+ - [Quick Start](quickstart.md)
5
+
6
+ - Guides
7
+
8
+ - [Embedding Guide](embedding-guide.md)
9
+ - [Router Integration](router-integration.md)
10
+ - [Templates & Styling](templates-and-styling.md)
11
+
12
+ - Reference
13
+
14
+ - [Architecture](architecture.md)
15
+ - [Configuration](configuration.md)
16
+ - [API Reference](api-reference.md)
17
+ - [Code Snippets](code-snippets.md)
18
+
19
+ - Retold Ecosystem
20
+
21
+ - [Pict](/pict/pict/)
22
+ - [Pict View](/pict/pict-view/)
23
+ - [Pict Router](/pict/pict-router/)
24
+ - [Pict Application](/pict/pict-application/)
25
+ - [Orator Authentication](/orator/orator-authentication/)
26
+ - [Fable](/fable/fable/)
@@ -0,0 +1,10 @@
1
+ # Pict Section Login
2
+
3
+ - [Overview](README.md)
4
+ - [Quick Start](quickstart.md)
5
+ - [Embedding](embedding-guide.md)
6
+ - [Router Integration](router-integration.md)
7
+ - [Architecture](architecture.md)
8
+ - [API Reference](api-reference.md)
9
+ - [Code Snippets](code-snippets.md)
10
+ - [GitHub](https://github.com/stevenvelozo/pict-section-login)
@@ -0,0 +1,7 @@
1
+ {
2
+ "Name": "pict-section-login",
3
+ "Version": "0.0.1",
4
+ "Description": "Pict login section for authentication UIs — works with orator-authentication or any custom backend",
5
+ "GeneratedAt": "2026-04-10T17:25:37.018Z",
6
+ "GitCommit": "e785649"
7
+ }
@@ -0,0 +1,239 @@
1
+ # API Reference
2
+
3
+ Every developer-facing method, property, and override hook on `PictSectionLogin`. Signatures follow the source in `source/Pict-Section-Login.js`.
4
+
5
+ `PictSectionLogin` extends [`pict-view`](https://github.com/stevenvelozo/pict-view), so it inherits all of the standard view lifecycle methods (`render`, `solve`, `initialize`, `onBeforeInitialize`, `onAfterRender`, `onAfterInitialRender`) in addition to the login-specific surface below.
6
+
7
+ ## Public State
8
+
9
+ Instance properties that the view maintains and that your code is welcome to read (but should generally not write directly):
10
+
11
+ ### `this.authenticated`
12
+
13
+ - **Type:** `boolean`
14
+ - **Default:** `false`
15
+ - `true` after a successful `login()` or a successful `checkSession()` that returned `LoggedIn: true`.
16
+ - Reset to `false` by `logout()`.
17
+
18
+ ### `this.sessionData`
19
+
20
+ - **Type:** `object | null`
21
+ - **Default:** `null`
22
+ - The most recent session object returned from the backend. Mirrored to `options.SessionDataAddress` via `fable.manifest.setValueByHash`.
23
+ - Cleared by `logout()`.
24
+
25
+ ### `this.oauthProviders`
26
+
27
+ - **Type:** `array`
28
+ - **Default:** `[]`
29
+ - Populated by `loadOAuthProviders()`. Each element is whatever the backend returned; `Name` is required, `BeginURL` is optional.
30
+
31
+ ### `this.initialRenderComplete`
32
+
33
+ - **Type:** `boolean`
34
+ - **Default:** `false`
35
+ - Internal flag; `true` after `onAfterInitialRender()` has run for the first time. Used to guard against duplicate CSS injection and duplicate session checks.
36
+
37
+ ## Authentication Methods
38
+
39
+ ### `login(pUsername, pPassword, fCallback)`
40
+
41
+ Authenticates against `options.LoginEndpoint`.
42
+
43
+ | Param | Type | Description |
44
+ |---|---|---|
45
+ | `pUsername` | `string` | The user-supplied username. |
46
+ | `pPassword` | `string` | The user-supplied password. |
47
+ | `fCallback` | `function(pError, pSessionData)` | Optional. Called with an error string on failure or the session object on success. |
48
+
49
+ Behavior:
50
+
51
+ 1. When `options.LoginMethod === 'POST'` (the default), sends `POST options.LoginEndpoint` with body `{ UserName, Password }` and `Content-Type: application/json`.
52
+ 2. When `options.LoginMethod === 'GET'`, sends `GET options.LoginEndpoint/:encodedUsername/:encodedPassword`.
53
+ 3. On success (response has `LoggedIn === true`):
54
+ - Sets `this.authenticated = true`.
55
+ - Assigns the response to `this.sessionData`.
56
+ - Calls `fable.manifest.setValueByHash(..., options.SessionDataAddress, sessionData)`.
57
+ - Renders the status bar (replaces the form).
58
+ - Calls `this.onLoginSuccess(sessionData)`.
59
+ - Calls `this.pict.PictApplication.solve()` when that method is available.
60
+ - Invokes `fCallback(null, sessionData)`.
61
+ 4. On failure:
62
+ - Renders the error template with the response's message.
63
+ - Calls `this.onLoginFailed(errorMessage)`.
64
+ - Invokes `fCallback(errorMessage)`.
65
+
66
+ Called automatically when the user submits the login form; you rarely need to call it directly unless you are driving the view programmatically (tests, SSO handoff, etc.).
67
+
68
+ ### `logout(fCallback)`
69
+
70
+ Ends the current session.
71
+
72
+ | Param | Type | Description |
73
+ |---|---|---|
74
+ | `fCallback` | `function(pError)` | Optional. Called when the logout flow finishes. |
75
+
76
+ Behavior:
77
+
78
+ 1. Sends `GET options.LogoutEndpoint`.
79
+ 2. Regardless of the network outcome, clears local state:
80
+ - `this.authenticated = false`
81
+ - `this.sessionData = null`
82
+ - `fable.manifest.setValueByHash(..., options.SessionDataAddress, null)`
83
+ 3. Re-renders the login form (replaces the status bar).
84
+ 4. Calls `this.onLogout()`.
85
+ 5. Calls `this.pict.PictApplication.solve()` when that method is available.
86
+ 6. Invokes `fCallback(null)` or `fCallback(errorString)`.
87
+
88
+ Wired up automatically to the logout button in the status bar template. Call it manually from an application-level logout action if your application has its own logout affordance (e.g. a menu item).
89
+
90
+ ### `checkSession(fCallback)`
91
+
92
+ Validates the current session against `options.CheckSessionEndpoint`.
93
+
94
+ | Param | Type | Description |
95
+ |---|---|---|
96
+ | `fCallback` | `function(pError, pSessionData)` | Optional. Called with an error string on network failure or the session object (which may have `LoggedIn: false`) on success. |
97
+
98
+ Behavior:
99
+
100
+ 1. Sends `GET options.CheckSessionEndpoint`.
101
+ 2. If the response has `LoggedIn === true`:
102
+ - Sets `this.authenticated = true`.
103
+ - Assigns the response to `this.sessionData`.
104
+ - Writes the session to `options.SessionDataAddress`.
105
+ - Renders the status bar.
106
+ 3. If `LoggedIn` is not true, leaves the login form visible.
107
+ 4. Calls `this.onSessionChecked(sessionData)` (or `this.onSessionChecked(null)` on network failure).
108
+ 5. Invokes `fCallback(pError, sessionData)`.
109
+
110
+ Called automatically after the first render when `options.CheckSessionOnLoad === true` (the default). Call it manually when you want the host application to control the timing (e.g. `CheckSessionOnLoad: false` plus a call from `PictApplication.onAfterInitializeAsync`).
111
+
112
+ ### `loadOAuthProviders(fCallback)`
113
+
114
+ Fetches the OAuth provider list from `options.OAuthProvidersEndpoint`.
115
+
116
+ | Param | Type | Description |
117
+ |---|---|---|
118
+ | `fCallback` | `function(pError, pProviders)` | Optional. Called with an array of providers on success. |
119
+
120
+ Behavior:
121
+
122
+ 1. Sends `GET options.OAuthProvidersEndpoint`.
123
+ 2. Stores the returned `Providers` array in `this.oauthProviders`.
124
+ 3. Renders the OAuth button row into `#pict-login-oauth-area`.
125
+ 4. Each button's click navigates the browser to `<OAuthBeginEndpoint>/<providerName>` (or to `provider.BeginURL` if the provider object supplies one).
126
+ 5. Invokes `fCallback(pError, providers)`.
127
+
128
+ Called automatically after the first render when `options.ShowOAuthProviders === true`.
129
+
130
+ ## Override Hooks
131
+
132
+ These methods are no-ops by default. Subclass `PictSectionLogin` and override them to hook application logic into the auth flow. The framework calls them at the right time -- you never call them directly.
133
+
134
+ ### `onLoginSuccess(pSessionData)`
135
+
136
+ Called after a successful `login()`.
137
+
138
+ | Param | Type | Description |
139
+ |---|---|---|
140
+ | `pSessionData` | `object` | The session object returned from the backend. Always has `LoggedIn: true`. |
141
+
142
+ Typical use:
143
+
144
+ - Show the application shell (e.g. `this.pict.PictApplication.showProtectedApp()`).
145
+ - Redirect to a stored pending route (`this.pict.providers.PictRouter.navigate(this.pict.AppData.PendingRoute || '/Dashboard')`).
146
+ - Fire analytics.
147
+ - Load additional user data.
148
+
149
+ ### `onLoginFailed(pError)`
150
+
151
+ Called after a failed `login()`.
152
+
153
+ | Param | Type | Description |
154
+ |---|---|---|
155
+ | `pError` | `string` | Human-readable error message from the backend or the network layer. |
156
+
157
+ Typical use:
158
+
159
+ - Fire analytics on failed attempts.
160
+ - Show a custom error modal instead of the inline error template.
161
+ - Track rate limiting / lockout state.
162
+
163
+ ### `onLogout()`
164
+
165
+ Called after a successful `logout()`.
166
+
167
+ No parameters.
168
+
169
+ Typical use:
170
+
171
+ - Show the login view and hide the protected shell (`this.pict.PictApplication.showLogin()`).
172
+ - Clear application-level caches or in-memory state.
173
+ - Navigate to a public landing page.
174
+
175
+ ### `onSessionChecked(pSessionData)`
176
+
177
+ Called after `checkSession()` completes.
178
+
179
+ | Param | Type | Description |
180
+ |---|---|---|
181
+ | `pSessionData` | `object \| null` | The session object on success (may be `{ LoggedIn: false }`), or `null` on network failure. |
182
+
183
+ Typical use:
184
+
185
+ - Detect a restored session on app load and show the protected shell without requiring the user to re-enter credentials.
186
+ - Detect an expired session and show the login view with an appropriate message.
187
+ - Drive a "restoring session" splash screen off of the timing of this callback.
188
+
189
+ ## Lifecycle Hooks (Inherited from pict-view)
190
+
191
+ `PictSectionLogin` overrides three standard lifecycle hooks. If you override them in a subclass, call `super.<method>(...)` first so the base behavior still runs.
192
+
193
+ ### `onBeforeInitialize()`
194
+
195
+ Called before the view is initialized. Used internally to reset state before the first render. Override to run subclass-level setup that must happen before templates are registered.
196
+
197
+ ### `onAfterRender(pRenderable)`
198
+
199
+ Called after each render pass. Used internally to:
200
+
201
+ 1. Inject CSS via `this.pict.CSSMap.injectCSS()` (first render only).
202
+ 2. Render the login form or status bar into the wrapper based on `this.authenticated`.
203
+ 3. Wire up the submit handler and logout button.
204
+
205
+ Override carefully -- call `super.onAfterRender(pRenderable)` first and then add subclass-level DOM work.
206
+
207
+ ### `onAfterInitialRender()`
208
+
209
+ Called once after the first render. Used internally to:
210
+
211
+ 1. Run `checkSession()` when `CheckSessionOnLoad === true`.
212
+ 2. Run `loadOAuthProviders()` when `ShowOAuthProviders === true`.
213
+ 3. Set `this.initialRenderComplete = true`.
214
+
215
+ Override if you want to run one-time subclass setup that depends on the DOM being ready.
216
+
217
+ ## Static Exports
218
+
219
+ ### `PictSectionLogin.default_configuration`
220
+
221
+ The default configuration object (see [Configuration](configuration.md) for every key). Exported so you can merge it with your own options:
222
+
223
+ ```javascript
224
+ const libPictSectionLogin = require('pict-section-login');
225
+ const tmpDefaults = libPictSectionLogin.default_configuration;
226
+
227
+ const tmpOptions = Object.assign({}, tmpDefaults, {
228
+ "LoginEndpoint": "/api/auth/login"
229
+ });
230
+ ```
231
+
232
+ ## Error Handling Contract
233
+
234
+ The view does its best to keep the UI consistent with server state:
235
+
236
+ - Network failures are surfaced as strings through the error hook and the inline error template.
237
+ - `logout()` always clears local state, even if the server is unreachable. The user should never be stuck in an "I can't log out" loop.
238
+ - `checkSession()` treats a network failure as "session unknown" -- it calls `onSessionChecked(null)` and leaves the UI untouched.
239
+ - `login()` treats any response without `LoggedIn === true` as a failure, regardless of HTTP status. This is intentional: some backends return 200 with a failure flag.