fix: SSO on web

This commit is contained in:
Christian Pauly 2021-07-08 18:42:46 +02:00
parent 22674e6e3c
commit 30d4bc5c49
3 changed files with 19 additions and 7 deletions

View File

@ -57,14 +57,23 @@ void main() async {
BackgroundPush.clientOnly(client); BackgroundPush.clientOnly(client);
} }
final queryParameters = <String, String>{};
if (kIsWeb) {
queryParameters
.addAll(Uri.parse(html.window.location.href).queryParameters);
}
runZonedGuarded( runZonedGuarded(
() => runApp(PlatformInfos.isMobile () => runApp(PlatformInfos.isMobile
? AppLock( ? AppLock(
builder: (args) => FluffyChatApp(client: client), builder: (args) => FluffyChatApp(
client: client,
queryParameters: queryParameters,
),
lockScreen: LockScreen(), lockScreen: LockScreen(),
enabled: false, enabled: false,
) )
: FluffyChatApp(client: client)), : FluffyChatApp(client: client, queryParameters: queryParameters)),
SentryController.captureException, SentryController.captureException,
); );
} }
@ -72,8 +81,10 @@ void main() async {
class FluffyChatApp extends StatefulWidget { class FluffyChatApp extends StatefulWidget {
final Widget testWidget; final Widget testWidget;
final Client client; final Client client;
final Map<String, String> queryParameters;
const FluffyChatApp({Key key, this.testWidget, @required this.client}) const FluffyChatApp(
{Key key, this.testWidget, @required this.client, this.queryParameters})
: super(key: key); : super(key: key);
/// getInitialLink may rereturn the value multiple times if this view is /// getInitialLink may rereturn the value multiple times if this view is

View File

@ -15,7 +15,6 @@ import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:uni_links/uni_links.dart'; import 'package:uni_links/uni_links.dart';
import 'package:universal_html/html.dart' as html;
import '../main.dart'; import '../main.dart';
@ -85,9 +84,8 @@ class HomeserverPickerController extends State<HomeserverPicker> {
_initReceiveUri(); _initReceiveUri();
if (kIsWeb) { if (kIsWeb) {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
final token = final token = Matrix.of(context).widget.queryParameters['loginToken'];
Uri.parse(html.window.location.href).queryParameters['loginToken']; if (token != null) _loginWithToken(token);
_loginWithToken(token);
}); });
} }
} }

View File

@ -37,11 +37,14 @@ class Matrix extends StatefulWidget {
final Client client; final Client client;
final Map<String, String> queryParameters;
Matrix({ Matrix({
this.child, this.child,
@required this.router, @required this.router,
@required this.context, @required this.context,
@required this.client, @required this.client,
this.queryParameters,
Key key, Key key,
}) : super(key: key); }) : super(key: key);