Dispose current session when logout

This commit is contained in:
2025-03-15 21:11:49 +08:00
parent f03d80ba88
commit 1b7e668b3f
7 changed files with 63 additions and 9 deletions

View File

@ -5,6 +5,7 @@ import 'package:material_symbols_icons/symbols.dart';
import 'package:provider/provider.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:surface/providers/sn_network.dart';
import 'package:surface/providers/userinfo.dart';
import 'package:surface/types/auth.dart';
import 'package:surface/widgets/dialog.dart';
import 'package:surface/widgets/loading_indicator.dart';
@ -73,10 +74,18 @@ class _AccountAuthTicketState extends State<AccountAuthTicket> {
}
}
int? _currentTicketId;
@override
void initState() {
super.initState();
_fetchAuthTickets();
final ua = context.read<UserProvider>();
ua.atkClaims.then((value) {
if (value == null) return;
_currentTicketId = int.parse(value['sed']);
});
}
@override
@ -142,6 +151,11 @@ class _AccountAuthTicketState extends State<AccountAuthTicket> {
.format(ticket.lastGrantAt!.toLocal()))
])).fontSize(12).opacity(0.75),
const Gap(4),
if (_currentTicketId == ticket.id)
Text('authTicketCurrent'.tr())
.fontSize(11)
.bold()
.opacity(0.75),
Text('#${ticket.id}').fontSize(11).opacity(0.75),
],
),
@ -153,9 +167,11 @@ class _AccountAuthTicketState extends State<AccountAuthTicket> {
constraints: const BoxConstraints(),
padding: EdgeInsets.zero,
icon: const Icon(Symbols.logout),
onPressed: () {
_deleteAuthTicket(ticket);
},
onPressed: _currentTicketId == ticket.id
? null
: () {
_deleteAuthTicket(ticket);
},
),
],
).padding(horizontal: 16, vertical: 12);