MagicStarterDeviceApproveController class
The signed-in side of the device-code sign-in: shows who is asking for a session on a TV and approves or denies it.
The screen (MagicStarterConfig.deviceApproveRoute(), ?code=) opens with
open. A code is only ever looked up (GET auth/device/{code}), which
changes nothing: opening the page never approves. approve and deny are
what the person presses, and approve acts only on the code whose facts are
on screen; a different code in the field is looked up first (needsLookup).
Every code that arrives through open came from a URL, which a stranger
can forward and edit, so it is a link code whatever the URL's entry
says. When the lookup says the approval comes from another network the code
is dropped from the field and mustType asks for it to be typed from the
TV. entry: typed goes up only for a code the person typed in this visit;
entry: link for a route code left in place on the network that requested
it.
A 423 answer (the account has two-factor confirmed) is needsProof: the
screen gathers the proof with confirmIdentity and calls approve again
with it.
An answer that lands after forget or a newer lookup is dropped. The code never reaches a log line.
- Inheritance
-
- Object
- ChangeNotifier
- MagicStarterDeviceApproveController
- Mixed-in types
Constructors
Properties
- canApprove → bool
-
Whether Approve can be pressed: the field holds the code whose facts are
on screen.
no setter
- canDeny → bool
-
Whether Deny can be pressed: the code is still undecided, nothing is in
flight and the facts on screen still belong to the field (an empty field,
as after a must-type clear, counts).
no setter
- codeController → TextEditingController
-
The code field. Held here so the controller can empty it.
final
- error → String?
-
A sentence for the screen when the last step did not go through.
no setter
- facts → MagicStarterDeviceApproveFacts?
-
What the server said about the looked-up code, or
null.no setter - factsMatchField → bool
-
Whether the facts on screen belong to what the field holds so far: an
empty field, or the start of the looked-up code. A field that has moved
to another code hides them.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- initialized → bool
-
Whether the controller has been initialized.
no setterinherited
- isBusy → bool
-
Whether a request is in flight.
no setter
- isDisposed → bool
-
Whether the controller has been disposed.
no setterinherited
- issuedMinutesAgo → int
-
Whole minutes since the code was issued.
no setter
- lookedUpCode → String?
-
The code whose facts are on screen, as the TV prints it (
XXXX-XXXX), ornullbefore a lookup has answered.no setter - mustType → bool
-
Whether the code must be typed from the TV before Approve: it came in the
route and the approval is not on the network that requested it.
no setter
- needsLookup → bool
-
Whether the field holds a whole code other than the one whose facts are
on screen: the primary action looks it up instead of approving.
no setter
- proofError → String?
-
The server's sentence for a refused proof, or
null(a 423 has none).no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- status → MagicStarterDeviceApproveStatus
-
Where the approval stands.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
approve(
{Map< String, String> proof = const <String, String>{}}) → Future<MagicStarterDeviceApproveOutcome> -
Approves the TV, with
proofwhen the server asked for one. -
Authorize an action against the current
Auth.uservia theGate.inherited -
close(
) → void - Leaves for home once the approval is done.
-
deny(
) → Future< void> - Denies the TV: the code is spent and the TV is told no.
-
deviceApprove(
) → Widget - Render the device-approve view via registry key.
-
dispose(
) → void -
Runs
onCloseif it has not run yet, then releases the notifier.inherited -
forget(
) → void - Drops the code, its facts and any error without notifying: the screen calls it as it opens and as it leaves, when nobody listens.
-
forgetIntendedPath(
String path) → void -
Drops the stored intended url when its path is
path, and keeps any other one for navigateHome.inherited -
lookup(
) → Future< void> - Looks up the code in the field and shows its facts.
-
Navigate to wherever a signed-in user should land after authenticating.
inherited
-
Navigate to
pathwhen a navigator context is available.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
onClose(
) → void - Called when the controller is about to be disposed.
-
onInit(
) → void -
Called when the controller is first created.
inherited
-
open(
{String? code}) → Future< void> -
Opens the screen on the route's
codequery value, a link code. -
refreshUI(
) → void -
Refresh the UI by notifying listeners.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → MagicStarterDeviceApproveController
-
no setter
Static Methods
-
approvePath(
String code) → String -
POSTpath that approvescode(normalised). -
denyPath(
String code) → String -
POSTpath that deniescode(normalised). -
lookupPath(
String code) → String -
GETpath that reads whatcode(normalised) stands for. -
normaliseCode(
String raw) → String - The code as the server keeps it: upper case, with every character outside the alphabet (the dash, spaces) dropped.