fix: on SSO registration, pass langcode to onboarding pages (#4235)
This commit is contained in:
parent
6dddefcb6d
commit
2bd41a58a4
2 changed files with 29 additions and 15 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:fluffychat/pangea/course_plans/course_plan_room_extension.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import '../common/controllers/pangea_controller.dart';
|
||||
|
||||
class PAuthGaurd {
|
||||
|
|
@ -55,7 +55,10 @@ class PAuthGaurd {
|
|||
// and their URL doesn’t include ‘course,’ redirect
|
||||
final bool hasSetL2 = await pController!.userController.isUserL2Set;
|
||||
final bool inCourse = Matrix.of(context).client.rooms.any(
|
||||
(r) => r.isSpace && r.coursePlan != null,
|
||||
(r) =>
|
||||
r.isSpace &&
|
||||
r.membership == Membership.join &&
|
||||
r.coursePlan != null,
|
||||
) ||
|
||||
state.fullPath?.contains('course') == true;
|
||||
|
||||
|
|
@ -81,6 +84,17 @@ class PAuthGaurd {
|
|||
final isLogged = Matrix.of(context).widget.clients.any(
|
||||
(client) => client.isLogged(),
|
||||
);
|
||||
return isLogged ? null : '/home';
|
||||
if (!isLogged) {
|
||||
return '/home';
|
||||
}
|
||||
|
||||
final bool hasSetL2 = await pController!.userController.isUserL2Set;
|
||||
final bool inCourse = Matrix.of(context).client.rooms.any(
|
||||
(r) =>
|
||||
r.isSpace &&
|
||||
r.membership == Membership.join &&
|
||||
r.coursePlan != null,
|
||||
);
|
||||
return hasSetL2 && inCourse ? '/rooms' : null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,14 +54,18 @@ Future<void> pangeaSSOLoginAction(
|
|||
final token = Uri.parse(result).queryParameters['loginToken'];
|
||||
if (token?.isEmpty ?? false) return;
|
||||
|
||||
final langCode = FluffyChatApp.router.state.pathParameters['langcode'];
|
||||
final path = langCode != null ? '/registration/$langCode' : '/registration';
|
||||
|
||||
final redirect = client.onLoginStateChanged.stream
|
||||
.where((state) => state == LoginState.loggedIn)
|
||||
.first
|
||||
.then(
|
||||
(_) {
|
||||
final route = FluffyChatApp.router.state.fullPath;
|
||||
if (route == null || !route.contains("/rooms")) {
|
||||
context.go("/rooms");
|
||||
if (route == null ||
|
||||
(!route.contains("/rooms") && !route.contains('registration'))) {
|
||||
context.go(path);
|
||||
}
|
||||
},
|
||||
).timeout(const Duration(seconds: 30));
|
||||
|
|
@ -70,17 +74,13 @@ Future<void> pangeaSSOLoginAction(
|
|||
LoginType.mLoginToken,
|
||||
token: token,
|
||||
initialDeviceDisplayName: PlatformInfos.clientName,
|
||||
onInitStateChanged: (state) {
|
||||
if (state == InitState.settingUpEncryption) {
|
||||
context.go("/rooms");
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if (client.onLoginStateChanged.value == LoginState.loggedIn) {
|
||||
final route = FluffyChatApp.router.state.fullPath;
|
||||
if (route == null || !route.contains("/rooms")) {
|
||||
context.go("/rooms");
|
||||
if (route == null ||
|
||||
(!route.contains("/rooms") && !route.contains('registration'))) {
|
||||
context.go(path);
|
||||
}
|
||||
} else {
|
||||
await redirect;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue