mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 14:59:29 +01:00
fix: Set homeserver from localstorage in web
This commit is contained in:
parent
cefa4be534
commit
65342a36a3
@ -1,7 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:famedlysdk/famedlysdk.dart';
|
||||
import 'package:fluffychat/pages/sign_up.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/config/app_config.dart';
|
||||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
@ -31,13 +33,21 @@ class HomeserverPickerController extends State<HomeserverPicker> {
|
||||
|
||||
void _loginWithToken(String token) {
|
||||
if (token?.isEmpty ?? true) return;
|
||||
|
||||
showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.login(
|
||||
type: AuthenticationTypes.token,
|
||||
token: token,
|
||||
initialDeviceDisplayName: PlatformInfos.clientName,
|
||||
),
|
||||
future: () async {
|
||||
if (Matrix.of(context).client.homeserver == null) {
|
||||
await Matrix.of(context).client.checkHomeserver(
|
||||
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;
|
||||
}
|
||||
|
||||
static const String _ssoHomeserverKey = 'sso-homeserver';
|
||||
static const String ssoHomeserverKey = 'sso-homeserver';
|
||||
|
||||
void ssoLoginAction(String id) {
|
||||
if (kIsWeb) {
|
||||
// We store the homserver in the local storage instead of a redirect
|
||||
// parameter because of possible CSRF attacks.
|
||||
Store().setItem(
|
||||
_ssoHomeserverKey, Matrix.of(context).client.homeserver.toString());
|
||||
ssoHomeserverKey, Matrix.of(context).client.homeserver.toString());
|
||||
}
|
||||
final redirectUrl = kIsWeb
|
||||
? html.window.location.href
|
||||
|
Loading…
Reference in New Issue
Block a user