KMP PHP API Reference

QuickLoginDeviceService
in package
uses LocatorAwareTrait

Manages quick-login device enrollment, metadata collection, and removal.

Covers device PIN persistence, user-agent parsing for OS/browser detection, and geolocation hint extraction from proxy headers. Controller-layer concerns (session, flash, authorization) remain in MembersController.

Table of Contents

Methods

collectDeviceMetadata()  : array<string, string|null>
Build metadata for quick-login device enrollment from request context.
collectUsageMetadata()  : array<string, string|null>
Collect usage metadata (IP and location) for quick-login events.
detectBrowser()  : string|null
Derive a friendly browser label from a user-agent string.
detectOperatingSystem()  : string|null
Derive a friendly operating-system label from a user-agent string.
extractLocationHint()  : string|null
Build a best-effort location hint from available proxy headers.
saveDevicePin()  : bool
Persist or update a quick-login device PIN and metadata for a member.
truncateString()  : string|null
Trim and truncate an optional string to the configured maximum length.

Methods

collectDeviceMetadata()

Build metadata for quick-login device enrollment from request context.

public collectDeviceMetadata(string|null $userAgent, string|null $clientIp[, array<string, string> $headers = [] ]) : array<string, string|null>
Parameters
$userAgent : string|null

Raw User-Agent header value.

$clientIp : string|null

Client IP address.

$headers : array<string, string> = []

Proxy headers for location hints.

Return values
array<string, string|null>

collectUsageMetadata()

Collect usage metadata (IP and location) for quick-login events.

public collectUsageMetadata(string|null $clientIp[, array<string, string> $headers = [] ]) : array<string, string|null>
Parameters
$clientIp : string|null

Client IP address.

$headers : array<string, string> = []

Proxy headers for location hints.

Return values
array<string, string|null>

detectBrowser()

Derive a friendly browser label from a user-agent string.

public detectBrowser(string $userAgent) : string|null
Parameters
$userAgent : string

HTTP user-agent header value.

Return values
string|null

Detected browser label or null when unavailable.

detectOperatingSystem()

Derive a friendly operating-system label from a user-agent string.

public detectOperatingSystem(string $userAgent) : string|null
Parameters
$userAgent : string

HTTP user-agent header value.

Return values
string|null

Detected OS label or null when unavailable.

extractLocationHint()

Build a best-effort location hint from available proxy headers.

public extractLocationHint([array<string, string> $headers = [] ]) : string|null
Parameters
$headers : array<string, string> = []

Map of header names to values.

Return values
string|null

Location summary or null when unavailable.

saveDevicePin()

Persist or update a quick-login device PIN and metadata for a member.

public saveDevicePin(Member $member, string $deviceId, string $pin[, array<string, string|null> $metadata = [] ]) : bool
Parameters
$member : Member

Member enabling quick login.

$deviceId : string

Stable browser/device identifier.

$pin : string

Raw numeric PIN to hash and store.

$metadata : array<string, string|null> = []

Enrollment metadata.

Return values
bool

True when the device record was saved.

truncateString()

Trim and truncate an optional string to the configured maximum length.

private truncateString(string|null $value, int $maxLength) : string|null
Parameters
$value : string|null

Raw string value.

$maxLength : int

Maximum allowed length.

Return values
string|null

Normalized string or null when empty.


        
On this page

Search results