fix: Set homeserver from localstorage in web
This commit is contained in:
parent
cefa4be534
commit
65342a36a3
|
@ -1,7 +1,9 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:famedlysdk/famedlysdk.dart';
|
import 'package:famedlysdk/famedlysdk.dart';
|
||||||
|
import 'package:fluffychat/pages/sign_up.dart';
|
||||||
import 'package:fluffychat/pages/views/homeserver_picker_view.dart';
|
import 'package:fluffychat/pages/views/homeserver_picker_view.dart';
|
||||||
|
import 'package:fluffychat/utils/famedlysdk_store.dart';
|
||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
import 'package:fluffychat/config/app_config.dart';
|
import 'package:fluffychat/config/app_config.dart';
|
||||||
import 'package:fluffychat/config/setting_keys.dart';
|
import 'package:fluffychat/config/setting_keys.dart';
|
||||||
|
@ -31,13 +33,21 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||||
|
|
||||||
void _loginWithToken(String token) {
|
void _loginWithToken(String token) {
|
||||||
if (token?.isEmpty ?? true) return;
|
if (token?.isEmpty ?? true) return;
|
||||||
|
|
||||||
showFutureLoadingDialog(
|
showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
future: () => Matrix.of(context).client.login(
|
future: () async {
|
||||||
type: AuthenticationTypes.token,
|
if (Matrix.of(context).client.homeserver == null) {
|
||||||
token: token,
|
await Matrix.of(context).client.checkHomeserver(
|
||||||
initialDeviceDisplayName: PlatformInfos.clientName,
|
await Store().getItem(SignUpController.ssoHomeserverKey),
|
||||||
),
|
);
|
||||||
|
}
|
||||||
|
await Matrix.of(context).client.login(
|
||||||
|
type: AuthenticationTypes.token,
|
||||||
|
token: token,
|
||||||
|
initialDeviceDisplayName: PlatformInfos.clientName,
|
||||||
|
);
|
||||||
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,14 +65,14 @@ class SignUpController extends State<SignUp> {
|
||||||
return _rawLoginTypes;
|
return _rawLoginTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const String _ssoHomeserverKey = 'sso-homeserver';
|
static const String ssoHomeserverKey = 'sso-homeserver';
|
||||||
|
|
||||||
void ssoLoginAction(String id) {
|
void ssoLoginAction(String id) {
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
// We store the homserver in the local storage instead of a redirect
|
// We store the homserver in the local storage instead of a redirect
|
||||||
// parameter because of possible CSRF attacks.
|
// parameter because of possible CSRF attacks.
|
||||||
Store().setItem(
|
Store().setItem(
|
||||||
_ssoHomeserverKey, Matrix.of(context).client.homeserver.toString());
|
ssoHomeserverKey, Matrix.of(context).client.homeserver.toString());
|
||||||
}
|
}
|
||||||
final redirectUrl = kIsWeb
|
final redirectUrl = kIsWeb
|
||||||
? html.window.location.href
|
? html.window.location.href
|
||||||
|
|
Loading…
Reference in New Issue