tree wide: check if build context is still valid after async call
> Storing BuildContext for later usage can easily lead to difficult
> to diagnose crashes. Asynchronous gaps are implicitly storing
> BuildContext and are some of the easiest to overlook when writing
> code.
>
> When a BuildContext is used, a mounted property must be checked
> after an asynchronous gap, depending on how the BuildContext is
> accessed:
>
> * When using a State's context property, the State's mounted
> property must be checked.
> * For other BuildContext instances (like a local variable or
> function argument), the BuildContext's mounted property must be
> checked.
we use path based dependencies for this proxmox specific libraries
that we do not plan to publish to a official dart package registry
like pub.dev so just mark them as not-for publishing for now.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
adapt to toggleableActiveColor property having been deprecated
ThemeData's toggleableActiveColor property has been deprecated [0].
This fix was done by `dart fix --apply` and thus is naturally a
relative broad automatic fix where we might only require a subset
from, but for now just trust the linter to do the safe thing.
login form: make onOriginSubmitted a required callback
as an user can hit enter on the field to start a submission even if
the submit button is disabled, e.g., due to no origin value being
entered at all yet.
Basically we already had that as contract, as forced dereferencing
via ! for accessing the callback.
As the callback already checks the validation state itself we do not
need to change anything there.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
saved login: don't give outdated ticket to login form
if the user was logged in in the past, but that ticket expired, we still
gave the expired ticket to the login form which tried to login with
that, producing a login error the first time the user pressed login.
we already get the correct ticket in a variable, so use that.
tfa: only open tfa form when there is at least one type available
Otherwise the tfa form will error out trying to access an index in the
array that does not exist (it assumes there is at least one type).
This can happen e.g. if there is only webauthn for a user configured
use the initState method to avoid that we override the initial
selected TFA method on every re-build and also to avoid running into
a transitive error when TFA login suceeded, as the handler for that
in the API dart lib will set tfa to null then, causing a null
dereference error if we'd get that in the (re)build method.
Co-authored-by: Wolfgang Bumiller <w.bumiller@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
The port 443 check was not triggered as 'hasPort' was already false.
Only add the port 443 to the IP/Url is the check was successful, otherwise
we leave the entered IP/Url as is. The use will need to fix it before we
can try to connect again.
login form: try port 8006 and 443 if none is given
but only if we really have any error that we cannot parse and would show
the 'could not connect' dialog
since the Uri object does not print the ':443' when calling 'toString()'
on the origin, we have to manually add when we read from the storage,
otherwise we'd retry 8006 every time instead of only once
uses 'biometric_storage' to save passwords secured by the platform
biometric method (e.g. fingerprint).
fingerprint is necessary when saving the password, as well as everytime
we need to read the password, e.g. selecting a login with a saved
password from the list.
instead of using a bool flag for that. in case the login and realm
selector both start, but one is finished before the other, the loading
mask vanished without explanation.
this way, we remove the mask only when both are finished
move the if(snapshot.hasData) check into the onPressed handler instead
of generating a new widget, that way the widget is not recreated
every time the condition changes and the code gets much shorter
Dominik Csapak [Thu, 1 Dec 2022 09:27:34 +0000 (10:27 +0100)]
login: fix login for saved ipv6 addresses
Since we only string concatenated the host + port, ipv6 addresses were
invalid because their missing [] around the ip. To fix that, use
'Uri's 'toString' method but strip the 'https://' prefix when creating
an Uri object again
This now also allows to enter the 'https://' prefix manually
default primary color was a purple hue that did not really fit with our
theme. That was used on highlighting form fields and the progress
indicator. I replaced it with orange since that fits nicely with
the rest of the look and feel
also removed the use of accentColor int he ProxmoxProgressOverlay, so
that the text appears now white instead of some shade of cyan.
since flutter 3 removed FlatButton. For this we have to do the colors a
little different, so i moved the color/disabledColor into the
textButtonTheme, which does not modify anything else here.
Dominik Csapak [Mon, 20 Dec 2021 11:35:09 +0000 (12:35 +0100)]
TFA: improve color-readabillity for input
with the recent changes, the input field was invisible, adapting like
the login dialog - note this is still not using the correct colors that
the actual main app theme defines, as its always derived from the dark
default theme now.
Thomas Lamprecht [Thu, 10 Jun 2021 09:54:15 +0000 (11:54 +0200)]
TFA: fix awaiting TOTP verification page
The cast to the FutureOr<> type confuses dart/flutter nowadays:
flutter: type 'Future<dynamic>' is not a subtype of type 'FutureOr<ProxmoxApiClient>' in type cast
flutter: #0 _ProxmoxLoginPageState._onLoginButtonPressed (package:proxmox_login_manager/proxmox_login_form.dart:406:12)
<asynchronous suspension>
just drop it.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Fri, 12 Mar 2021 14:12:26 +0000 (15:12 +0100)]
migrate to sound null safety
tried to strike a balance between auto migration and checking what
can actually get null, or improve that by promoting some variables.
Learnt that for class fields dart cannot promote nullable fields to
null-safe after a if (field == null) return 'early'; check, so we
need to introduce a intermediate varibable and check on that - a bit
of a bummer..
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Wed, 23 Sep 2020 08:20:16 +0000 (10:20 +0200)]
fix issue when 443 port is used
The reason for this issue was that the dart Uri.hasPort[0] property
is queried when checking if the passed URL has no port added and thus
the implied 8006 port should be added. For https and port 443 the
port is detected as "default" and omitted, thus this is always false
for that, argh!
Just use a simple regex on the original trimmed origin text.
IPv6 must be wrapped in brackets so [::1] or [::1]:443 is also
correctly detected.