'${userModel.origin?.host}:${userModel.origin?.port}';
_accessDomains = _getAccessDomains();
_usernameController.text = userModel.username;
- if (widget.ticket.isNotEmpty) {
+ if (widget.ticket.isNotEmpty && userModel.activeSession) {
_onLoginButtonPressed(ticket: widget.ticket, mRealm: userModel.realm);
}
}
apiClient: client,
),
));
+
+ if (client == null) {
+ setState(() {
+ _progressModel.inProgress = false;
+ });
+ return;
+ }
}
final status = await client.getClusterStatus();
/// The username with the corresponding realm e.g. root@pam
String get fullUsername => '$username@$realm';
- bool get activeSession => ticket != null && ticket.isNotEmpty;
+ bool get activeSession =>
+ ticket != null && ticket.isNotEmpty && !ticketExpired();
@nullable
String get hostname;
static Serializer<ProxmoxLoginModel> get serializer =>
_$proxmoxLoginModelSerializer;
+
+ bool ticketExpired() {
+ final ticketRegex = RegExp(r'(PVE|PMG)(?:QUAR)?:(?:(\S+):)?([A-Z0-9]{8})::')
+ .firstMatch(ticket);
+ final time = DateTime.fromMillisecondsSinceEpoch(
+ int.parse(ticketRegex.group(3), radix: 16) * 1000);
+ return DateTime.now().isAfter(time.add(Duration(hours: 1)));
+ }
}
class ProxmoxProductType extends EnumClass {
Widget build(BuildContext context) {
return Theme(
data: ThemeData.dark().copyWith(accentColor: Color(0xFFE47225)),
- child: Material(
- color: Theme.of(context).primaryColor,
- child: Stack(
+ child: Scaffold(
+ backgroundColor: Theme.of(context).primaryColor,
+ extendBodyBehindAppBar: true,
+ appBar: AppBar(
+ elevation: 0.0,
+ backgroundColor: Colors.transparent,
+ leading: IconButton(
+ icon: Icon(Icons.close),
+ onPressed: () => Navigator.of(context).pop(),
+ ),
+ ),
+ body: Stack(
alignment: Alignment.center,
children: [
SingleChildScrollView(