fixes for SSO login errors on web
This commit is contained in:
parent
e826c61878
commit
0dbb04bba8
6 changed files with 55 additions and 48 deletions
|
|
@ -1,15 +1,14 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:collection/collection.dart' show IterableExtension;
|
||||
import 'package:fluffychat/pages/device_settings/device_settings_view.dart';
|
||||
import 'package:fluffychat/pages/key_verification/key_verification_dialog.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:matrix/encryption/utils/key_verification.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/pages/device_settings/device_settings_view.dart';
|
||||
import 'package:fluffychat/pages/key_verification/key_verification_dialog.dart';
|
||||
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
||||
import '../../widgets/matrix.dart';
|
||||
|
||||
class DevicesSettings extends StatefulWidget {
|
||||
|
|
@ -34,9 +33,6 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
|
||||
void removeDevicesAction(List<Device> devices) async {
|
||||
if (await showOkCancelAlertDialog(
|
||||
// #Pangea
|
||||
useRootNavigator: false,
|
||||
// Pangea#
|
||||
context: context,
|
||||
title: L10n.of(context)!.areYouSure,
|
||||
okLabel: L10n.of(context)!.yes,
|
||||
|
|
@ -72,9 +68,6 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
|
||||
void renameDeviceAction(Device device) async {
|
||||
final displayName = await showTextInputDialog(
|
||||
// #Pangea
|
||||
useRootNavigator: false,
|
||||
// Pangea#
|
||||
context: context,
|
||||
title: L10n.of(context)!.changeDeviceName,
|
||||
okLabel: L10n.of(context)!.ok,
|
||||
|
|
@ -98,7 +91,7 @@ class DevicesSettingsController extends State<DevicesSettings> {
|
|||
}
|
||||
|
||||
void verifyDeviceAction(Device device) async {
|
||||
final req = Matrix.of(context)
|
||||
final req = await Matrix.of(context)
|
||||
.client
|
||||
.userDeviceKeys[Matrix.of(context).client.userID!]!
|
||||
.deviceKeys[device.deviceId]!
|
||||
|
|
|
|||
|
|
@ -130,8 +130,11 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||
? '${html.window.origin!}/auth.html'
|
||||
: '${AppConfig.appOpenUrlScheme.toLowerCase()}://login';
|
||||
//Pangea#
|
||||
final url =
|
||||
'${Matrix.of(context).getLoginClient().homeserver?.toString()}/_matrix/client/r0/login/sso/redirect/${Uri.encodeComponent(id)}?redirectUrl=${Uri.encodeQueryComponent(redirectUrl)}';
|
||||
final url = Matrix.of(context).getLoginClient().homeserver!.replace(
|
||||
path: '/_matrix/client/v3/login/sso/redirect${id == null ? '' : '/$id'}',
|
||||
queryParameters: {'redirectUrl': redirectUrl},
|
||||
);
|
||||
|
||||
final urlScheme = isDefaultPlatform
|
||||
? Uri.parse(redirectUrl).scheme
|
||||
: "http://localhost:3001";
|
||||
|
|
@ -161,22 +164,33 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
|||
final token = Uri.parse(result).queryParameters['loginToken'];
|
||||
if (token?.isEmpty ?? false) return;
|
||||
|
||||
// #Pangea
|
||||
final loginRes = await showFutureLoadingDialog(
|
||||
// await showFutureLoadingDialog(
|
||||
// Pangea#
|
||||
context: context,
|
||||
future: () => Matrix.of(context).getLoginClient().login(
|
||||
setState(() {
|
||||
error = null;
|
||||
isLoading = isLoggingIn = true;
|
||||
});
|
||||
try {
|
||||
// #Pangea
|
||||
final loginRes = await Matrix.of(context).getLoginClient().login(
|
||||
// await Matrix.of(context).getLoginClient().login(
|
||||
// Pangea#
|
||||
LoginType.mLoginToken,
|
||||
token: token,
|
||||
initialDeviceDisplayName: PlatformInfos.clientName,
|
||||
),
|
||||
);
|
||||
//Pangea#
|
||||
if (loginRes.result != null) {
|
||||
GoogleAnalytics.login(provider.name!, loginRes.result!.userId);
|
||||
);
|
||||
// #Pangea
|
||||
GoogleAnalytics.login(provider.name!, loginRes.userId);
|
||||
// Pangea#
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
error = e.toLocalizedString(context);
|
||||
});
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
isLoading = isLoggingIn = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
//Pangea#
|
||||
}
|
||||
|
||||
List<IdentityProvider>? get identityProviders {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
import 'dart:developer';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/constants/class_default_values.dart';
|
||||
import 'package:fluffychat/pangea/controllers/class_controller.dart';
|
||||
import 'package:fluffychat/pangea/controllers/contextual_definition_controller.dart';
|
||||
|
|
@ -24,6 +18,11 @@ import 'package:fluffychat/pangea/utils/bot_name.dart';
|
|||
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
||||
import 'package:fluffychat/pangea/utils/instructions.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../../config/app_config.dart';
|
||||
import '../utils/firebase_analytics.dart';
|
||||
import '../utils/p_store.dart';
|
||||
|
|
@ -160,6 +159,8 @@ class PangeaController {
|
|||
|
||||
void startChatWithBotIfNotPresent() {
|
||||
Future.delayed(const Duration(milliseconds: 10000), () async {
|
||||
// check if user is logged in
|
||||
if (!matrixState.client.isLogged()) return;
|
||||
try {
|
||||
await matrixState.client.startDirectChat(
|
||||
BotName.byEnvironment,
|
||||
|
|
|
|||
|
|
@ -890,10 +890,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_web_auth_2
|
||||
sha256: "75613aa4d8e43df3de0fc3d93df36ae5b4ba2e94070384c5a9baeda99f5a235f"
|
||||
sha256: "3ea3a0cc539ca74319f4f2f7484f62742fe5b2ff9a0fca37575426d6e6f07901"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
version: "3.1.1"
|
||||
flutter_web_auth_2_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
@ -1386,10 +1386,10 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
name: matrix
|
||||
sha256: b01a8a7141a586853a4f9b2e98b3c9912ff74bbceadc16b2bf3630bf055a830a
|
||||
sha256: c5271ebe5a67d3af2b9490a05a538501b3a454f5eb2089f82cb18ddc9513455e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.22.7"
|
||||
version: "0.25.3"
|
||||
matrix_api_lite:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ dependencies:
|
|||
flutter_secure_storage: ^9.0.0
|
||||
flutter_svg: ^2.0.0+1
|
||||
flutter_typeahead: ^4.8.0
|
||||
flutter_web_auth_2: ^3.0.3
|
||||
flutter_web_auth_2: ^3.1.1
|
||||
flutter_webrtc: ^0.9.46
|
||||
future_loading_dialog: ^0.3.0
|
||||
geolocator: ^7.6.2
|
||||
|
|
@ -77,7 +77,7 @@ dependencies:
|
|||
language_tool: ^2.1.1
|
||||
latlong2: ^0.8.1
|
||||
linkify: ^5.0.0
|
||||
matrix: ^0.22.6
|
||||
matrix: ^0.25.3
|
||||
matrix_homeserver_recommendations: ^0.3.0
|
||||
native_imaging: ^0.1.0
|
||||
new_version_plus: ^0.0.10
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Authentication complete</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Authentication is complete. If this does not happen automatically, please
|
||||
close the window.
|
||||
<script>
|
||||
<title>Authentication complete</title>
|
||||
<p>Authentication is complete. If this does not happen automatically, please close the window.</p>
|
||||
<script>
|
||||
if (window.opener) {
|
||||
window.opener.postMessage({
|
||||
'flutter-web-auth-2': window.location.href
|
||||
}, window.location.origin);
|
||||
window.close();
|
||||
</script>
|
||||
</body>
|
||||
} else {
|
||||
localStorage.setItem('flutter-web-auth-2', window.location.href);
|
||||
}
|
||||
window.close();
|
||||
</script>
|
||||
Loading…
Add table
Reference in a new issue