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);
}
final queryParameters = <String, String>{};
if (kIsWeb) {
queryParameters
.addAll(Uri.parse(html.window.location.href).queryParameters);
}
runZonedGuarded(
() => runApp(PlatformInfos.isMobile
? AppLock(
builder: (args) => FluffyChatApp(client: client),
builder: (args) => FluffyChatApp(
client: client,
queryParameters: queryParameters,
),
lockScreen: LockScreen(),
enabled: false,
)
: FluffyChatApp(client: client)),
: FluffyChatApp(client: client, queryParameters: queryParameters)),
SentryController.captureException,
);
}
@ -72,8 +81,10 @@ void main() async {
class FluffyChatApp extends StatefulWidget {
final Widget testWidget;
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);
/// 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:future_loading_dialog/future_loading_dialog.dart';
import 'package:uni_links/uni_links.dart';
import 'package:universal_html/html.dart' as html;
import '../main.dart';
@ -85,9 +84,8 @@ class HomeserverPickerController extends State<HomeserverPicker> {
_initReceiveUri();
if (kIsWeb) {
WidgetsBinding.instance.addPostFrameCallback((_) {
final token =
Uri.parse(html.window.location.href).queryParameters['loginToken'];
_loginWithToken(token);
final token = Matrix.of(context).widget.queryParameters['loginToken'];
if (token != null) _loginWithToken(token);
});
}
}

View File

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