Skip to content

Commit

Permalink
Fix sso-only server login
Browse files Browse the repository at this point in the history
  • Loading branch information
Airyzz committed Jun 28, 2024
1 parent e43f385 commit 48b7fc1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
8 changes: 6 additions & 2 deletions commet/lib/client/matrix/matrix_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ class MatrixClient extends Client {
"m.room.power_levels",
"m.room.join_rules"
},
supportedLoginTypes: {matrix.AuthenticationTypes.password},
supportedLoginTypes: {
matrix.AuthenticationTypes.password,
matrix.AuthenticationTypes.sso
},
nativeImplementations: nativeImplementations,
databaseBuilder: (client) => getMatrixDatabase(client.clientName),
logLevel: BuildConfig.RELEASE ? matrix.Level.warning : matrix.Level.info,
Expand Down Expand Up @@ -574,7 +577,8 @@ class MatrixClient extends Client {
true,
resultFlows,
);
} catch (_) {
} catch (error, trace) {
Log.onError(error, trace);
return (false, null);
}
}
Expand Down
2 changes: 2 additions & 0 deletions commet/lib/ui/pages/login/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class LoginPageState extends State<LoginPage> {
isLoggingIn: isLoggingIn,
loadingServerInfo: loadingServerInfo,
hasSsoSupport: loginFlows?.whereType<SsoLoginFlow>().isNotEmpty == true,
hasPasswordSupport:
loginFlows?.whereType<PasswordLoginFlow>().isNotEmpty == true,
isServerValid: isServerValid,
);
}
Expand Down
42 changes: 22 additions & 20 deletions commet/lib/ui/pages/login/login_page_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class LoginPageView extends StatefulWidget {
this.loadingServerInfo = false,
this.isServerValid = false,
this.hasSsoSupport = false,
this.hasPasswordSupport = false,
this.updateHomeserver});
final bool canNavigateBack;
final bool isLoggingIn;
Expand All @@ -35,6 +36,7 @@ class LoginPageView extends StatefulWidget {
final bool loadingServerInfo;
final bool isServerValid;
final bool hasSsoSupport;
final bool hasPasswordSupport;
final Future<void> Function(SsoLoginFlow flow)? doSsoLogin;
final Future<void> Function(
PasswordLoginFlow flow, String username, String password)?
Expand Down Expand Up @@ -76,7 +78,6 @@ class _LoginPageViewState extends State<LoginPageView> {
_onHomeserverTextUpdated();
});
}

super.initState();
}

Expand Down Expand Up @@ -221,7 +222,7 @@ class _LoginPageViewState extends State<LoginPageView> {
const SizedBox(height: 16),
homeserverEntry(),
const SizedBox(height: 16),
usenamePasswordLoginInputs(),
if (widget.hasPasswordSupport) usenamePasswordLoginInputs(),
SizedBox(
height: 15,
child: Center(
Expand All @@ -238,23 +239,24 @@ class _LoginPageViewState extends State<LoginPageView> {
if (widget.hasSsoSupport)
Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
width: 100,
height: 10,
child: tiamat.Seperator(),
),
tiamat.Text.labelLow(CommonStrings.labelOr),
const SizedBox(
width: 100,
height: 10,
child: tiamat.Seperator(),
),
],
),
if (widget.hasPasswordSupport)
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const SizedBox(
width: 100,
height: 10,
child: tiamat.Seperator(),
),
tiamat.Text.labelLow(CommonStrings.labelOr),
const SizedBox(
width: 100,
height: 10,
child: tiamat.Seperator(),
),
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Wrap(
Expand Down Expand Up @@ -377,7 +379,7 @@ class _LoginPageViewState extends State<LoginPageView> {
height: 50,
child: SvgPicture.asset(
"assets/images/app_icon/icon.svg",
theme: SvgTheme(currentColor: Theme.of(context).colorScheme.onPrimary),
theme: SvgTheme(currentColor: Theme.of(context).colorScheme.onSurface),
),
);
}
Expand Down

0 comments on commit 48b7fc1

Please sign in to comment.