Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix: Update auth path for build #2092

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
4 changes: 3 additions & 1 deletion docs/configurations/config_web_app_for_public_platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ in [config.sample.json](https://github.com/linagora/twake-on-matrix/blob/main/co
"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
}
```

Expand All @@ -45,5 +46,6 @@ in [config.sample.json](https://github.com/linagora/twake-on-matrix/blob/main/co
- `homeserver`: Homeserver
- `platform`: Platform, `saas` for the case of public platform
- `default_max_upload_avatar_size_in_bytes`: Default max upload avatar size
- `dev_mode`: Enable to run app in IDE

If you want to disable it, please change the value or remove this from `config.sample.json`
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';
}
}
}