Skip to content

Commit

Permalink
Hotfix: Update auth path for build
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Oct 18, 2024
1 parent 6285c22 commit 4903d23
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
3 changes: 2 additions & 1 deletion config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
"app_grid_dashboard_available": true,
"homeserver": "https://example.com/",
"platform": "platform",
"default_max_upload_avatar_size_in_bytes": 1000000
"default_max_upload_avatar_size_in_bytes": 1000000,
"dev_mode": false
}
5 changes: 5 additions & 0 deletions lib/config/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ abstract class AppConfig {

static int defaultMaxUploadAvtarSizeInBytes = 10 * (1024 * 1024);

static bool devMode = false;

static const String appGridConfigurationPath =
"configurations/app_dashboard.json";

Expand Down Expand Up @@ -243,5 +245,8 @@ abstract class AppConfig {
defaultMaxUploadAvtarSizeInBytes =
json['default_max_upload_avatar_size_in_bytes'];
}
if (json['dev_mode'] is bool) {
devMode = json['dev_mode'];
}
}
}
13 changes: 9 additions & 4 deletions lib/presentation/mixins/connect_page_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,11 @@ mixin ConnectPageMixin {
String _generatePostLogoutRedirectUrl() {
if (kIsWeb) {
if (AppConfig.issueId != null && AppConfig.issueId!.isNotEmpty) {
return '${html.window.location.href.getBaseUrlBeforeHash()}/twake-on-matrix/${AppConfig.issueId}/auth.html';
return '${html.window.location.href.getBaseUrlBeforeHash()}auth.html';
}
return '${html.window.location.href.getBaseUrlBeforeHash()}web/auth.html';
return html.window.location.href
.getBaseUrlBeforeHash()
.generateAuthPath(isDevMode: AppConfig.devMode);
}
return '${AppConfig.appOpenUrlScheme.toLowerCase()}://redirect';
}
Expand All @@ -231,9 +233,12 @@ mixin ConnectPageMixin {
homeserverParam = '?homeserver=$homeserver';
}
if (AppConfig.issueId != null && AppConfig.issueId!.isNotEmpty) {
return '${html.window.location.href.getBaseUrlBeforeHash()}/twake-on-matrix/${AppConfig.issueId}/auth.html$homeserverParam';
return '${html.window.location.href.getBaseUrlBeforeHash()}auth.html$homeserverParam';
}
return '${html.window.location.href.getBaseUrlBeforeHash()}web/auth.html$homeserverParam';
return html.window.location.href.getBaseUrlBeforeHash().generateAuthPath(
homeserverParams: homeserverParam,
isDevMode: AppConfig.devMode,
);
}
return '${AppConfig.appOpenUrlScheme.toLowerCase()}://login';
}
Expand Down
11 changes: 11 additions & 0 deletions lib/utils/string_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,15 @@ extension StringCasingExtension on String {
final fragmentIndex = indexOf('#/');
return fragmentIndex != -1 ? substring(0, fragmentIndex) : this;
}

String generateAuthPath({
String? homeserverParams,
bool isDevMode = false,
}) {
if (isDevMode) {
return '${this}web/auth.html$homeserverParams';
} else {
return '${this}auth.html$homeserverParams';
}
}
}

0 comments on commit 4903d23

Please sign in to comment.