mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-02-25 19:00:45 +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 '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 {
|
||||||
|
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,
|
type: AuthenticationTypes.token,
|
||||||
token: token,
|
token: token,
|
||||||
initialDeviceDisplayName: PlatformInfos.clientName,
|
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…
x
Reference in New Issue
Block a user