fix: UIA request handler

This commit is contained in:
Christian Pauly 2022-10-17 10:43:09 +02:00
parent 6d70240c14
commit ef057b1775

View File

@ -9,6 +9,7 @@ import 'package:fluffychat/widgets/matrix.dart';
extension UiaRequestManager on MatrixState { extension UiaRequestManager on MatrixState {
Future uiaRequestHandler(UiaRequest uiaRequest) async { Future uiaRequestHandler(UiaRequest uiaRequest) async {
final l10n = L10n.of(navigatorContext)!;
try { try {
if (uiaRequest.state != UiaRequestState.waitForUser || if (uiaRequest.state != UiaRequestState.waitForUser ||
uiaRequest.nextStages.isEmpty) { uiaRequest.nextStages.isEmpty) {
@ -22,9 +23,9 @@ extension UiaRequestManager on MatrixState {
final input = cachedPassword ?? final input = cachedPassword ??
(await showTextInputDialog( (await showTextInputDialog(
context: navigatorContext, context: navigatorContext,
title: L10n.of(context)!.pleaseEnterYourPassword, title: l10n.pleaseEnterYourPassword,
okLabel: L10n.of(context)!.ok, okLabel: l10n.ok,
cancelLabel: L10n.of(context)!.cancel, cancelLabel: l10n.cancel,
textFields: [ textFields: [
const DialogTextField( const DialogTextField(
minLines: 1, minLines: 1,
@ -64,10 +65,10 @@ extension UiaRequestManager on MatrixState {
await showOkCancelAlertDialog( await showOkCancelAlertDialog(
useRootNavigator: false, useRootNavigator: false,
context: navigatorContext, context: navigatorContext,
title: L10n.of(context)!.weSentYouAnEmail, title: l10n.weSentYouAnEmail,
message: L10n.of(context)!.pleaseClickOnLink, message: l10n.pleaseClickOnLink,
okLabel: L10n.of(context)!.iHaveClickedOnLink, okLabel: l10n.iHaveClickedOnLink,
cancelLabel: L10n.of(context)!.cancel, cancelLabel: l10n.cancel,
)) { )) {
return uiaRequest.completeStage(auth); return uiaRequest.completeStage(auth);
} }
@ -90,10 +91,10 @@ extension UiaRequestManager on MatrixState {
if (OkCancelResult.ok == if (OkCancelResult.ok ==
await showOkCancelAlertDialog( await showOkCancelAlertDialog(
useRootNavigator: false, useRootNavigator: false,
message: L10n.of(context)!.pleaseFollowInstructionsOnWeb, message: l10n.pleaseFollowInstructionsOnWeb,
context: navigatorContext, context: navigatorContext,
okLabel: L10n.of(context)!.next, okLabel: l10n.next,
cancelLabel: L10n.of(context)!.cancel, cancelLabel: l10n.cancel,
)) { )) {
return uiaRequest.completeStage( return uiaRequest.completeStage(
AuthenticationData(session: uiaRequest.session), AuthenticationData(session: uiaRequest.session),