mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
fix: login issue (#4546)
* fix: reset server url when using appflowy cloud the first time * refactor: set authenticator in frontend * chore: log version * chore: show hint when changing the server type * chore: bump version * chore: fix test * chore: bump collab
This commit is contained in:
@ -52,6 +52,7 @@ class AppFlowyCloudSettingBloc
|
||||
emit(
|
||||
state.copyWith(
|
||||
setting: setting,
|
||||
showRestartHint: setting.serverUrl.isNotEmpty,
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -75,11 +76,13 @@ class AppFlowyCloudSettingEvent with _$AppFlowyCloudSettingEvent {
|
||||
class AppFlowyCloudSettingState with _$AppFlowyCloudSettingState {
|
||||
const factory AppFlowyCloudSettingState({
|
||||
required CloudSettingPB setting,
|
||||
required bool showRestartHint,
|
||||
}) = _AppFlowyCloudSettingState;
|
||||
|
||||
factory AppFlowyCloudSettingState.initial(CloudSettingPB setting) =>
|
||||
AppFlowyCloudSettingState(
|
||||
setting: setting,
|
||||
showRestartHint: setting.serverUrl.isNotEmpty,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -16,24 +16,29 @@ class AppFlowyCloudURLsBloc
|
||||
await event.when(
|
||||
initial: () async {},
|
||||
updateServerUrl: (url) {
|
||||
emit(state.copyWith(updatedServerUrl: url));
|
||||
emit(
|
||||
state.copyWith(
|
||||
updatedServerUrl: url,
|
||||
urlError: none(),
|
||||
showRestartHint: url.isNotEmpty,
|
||||
),
|
||||
);
|
||||
},
|
||||
confirmUpdate: () async {
|
||||
if (state.updatedServerUrl.isEmpty) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
updatedServerUrl: "",
|
||||
urlError: none(),
|
||||
restartApp: true,
|
||||
urlError: Some(
|
||||
LocaleKeys.settings_menu_appFlowyCloudUrlCanNotBeEmpty.tr(),
|
||||
),
|
||||
restartApp: false,
|
||||
),
|
||||
);
|
||||
await setAppFlowyCloudUrl(none());
|
||||
} else {
|
||||
validateUrl(state.updatedServerUrl).fold(
|
||||
(url) async {
|
||||
if (state.config.base_url != url) {
|
||||
await setAppFlowyCloudUrl(Some(url));
|
||||
}
|
||||
await useSelfHostedAppFlowyCloudWithURL(url);
|
||||
add(const AppFlowyCloudURLsEvent.didSaveConfig());
|
||||
},
|
||||
(err) => emit(state.copyWith(urlError: Some(err))),
|
||||
@ -69,6 +74,7 @@ class AppFlowyCloudURLsState with _$AppFlowyCloudURLsState {
|
||||
required String updatedServerUrl,
|
||||
required Option<String> urlError,
|
||||
required bool restartApp,
|
||||
required bool showRestartHint,
|
||||
}) = _AppFlowyCloudURLsState;
|
||||
|
||||
factory AppFlowyCloudURLsState.initial() => AppFlowyCloudURLsState(
|
||||
@ -76,6 +82,10 @@ class AppFlowyCloudURLsState with _$AppFlowyCloudURLsState {
|
||||
urlError: none(),
|
||||
updatedServerUrl:
|
||||
getIt<AppFlowyCloudSharedEnv>().appflowyCloudConfig.base_url,
|
||||
showRestartHint: getIt<AppFlowyCloudSharedEnv>()
|
||||
.appflowyCloudConfig
|
||||
.base_url
|
||||
.isNotEmpty,
|
||||
restartApp: false,
|
||||
);
|
||||
}
|
||||
|
@ -19,49 +19,63 @@ class SupabaseCloudURLsBloc
|
||||
on<SupabaseCloudURLsEvent>((event, emit) async {
|
||||
await event.when(
|
||||
updateUrl: (String url) {
|
||||
emit(state.copyWith(updatedUrl: url));
|
||||
emit(
|
||||
state.copyWith(
|
||||
updatedUrl: url,
|
||||
showRestartHint: url.isNotEmpty && state.upatedAnonKey.isNotEmpty,
|
||||
urlError: none(),
|
||||
),
|
||||
);
|
||||
},
|
||||
updateAnonKey: (String anonKey) {
|
||||
emit(state.copyWith(upatedAnonKey: anonKey));
|
||||
emit(
|
||||
state.copyWith(
|
||||
upatedAnonKey: anonKey,
|
||||
showRestartHint:
|
||||
anonKey.isNotEmpty && state.updatedUrl.isNotEmpty,
|
||||
anonKeyError: none(),
|
||||
),
|
||||
);
|
||||
},
|
||||
confirmUpdate: () async {
|
||||
if (state.updatedUrl.isEmpty) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
urlError: none(),
|
||||
urlError: Some(
|
||||
LocaleKeys.settings_menu_cloudSupabaseUrlCanNotBeEmpty.tr(),
|
||||
),
|
||||
anonKeyError: none(),
|
||||
restartApp: true,
|
||||
restartApp: false,
|
||||
),
|
||||
);
|
||||
await setSupbaseServer(none(), none());
|
||||
} else {
|
||||
// The anon key can't be empty if the url is not empty.
|
||||
if (state.upatedAnonKey.isEmpty) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
urlError: none(),
|
||||
anonKeyError: some(
|
||||
LocaleKeys.settings_menu_cloudSupabaseAnonKeyCanNotBeEmpty
|
||||
.tr(),
|
||||
),
|
||||
restartApp: false,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
validateUrl(state.updatedUrl).fold(
|
||||
(error) => emit(state.copyWith(urlError: Some(error))),
|
||||
(_) async {
|
||||
await setSupbaseServer(
|
||||
Some(state.updatedUrl),
|
||||
Some(state.upatedAnonKey),
|
||||
);
|
||||
|
||||
add(const SupabaseCloudURLsEvent.didSaveConfig());
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state.upatedAnonKey.isEmpty) {
|
||||
emit(
|
||||
state.copyWith(
|
||||
urlError: none(),
|
||||
anonKeyError: Some(
|
||||
LocaleKeys.settings_menu_cloudSupabaseAnonKeyCanNotBeEmpty
|
||||
.tr(),
|
||||
),
|
||||
restartApp: false,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
validateUrl(state.updatedUrl).fold(
|
||||
(error) => emit(state.copyWith(urlError: Some(error))),
|
||||
(_) async {
|
||||
await useSupabaseCloud(
|
||||
url: state.updatedUrl,
|
||||
anonKey: state.upatedAnonKey,
|
||||
);
|
||||
|
||||
add(const SupabaseCloudURLsEvent.didSaveConfig());
|
||||
},
|
||||
);
|
||||
},
|
||||
didSaveConfig: () {
|
||||
emit(
|
||||
@ -99,6 +113,7 @@ class SupabaseCloudURLsState with _$SupabaseCloudURLsState {
|
||||
required Option<String> urlError,
|
||||
required Option<String> anonKeyError,
|
||||
required bool restartApp,
|
||||
required bool showRestartHint,
|
||||
}) = _SupabaseCloudURLsState;
|
||||
|
||||
factory SupabaseCloudURLsState.initial() {
|
||||
@ -109,6 +124,7 @@ class SupabaseCloudURLsState with _$SupabaseCloudURLsState {
|
||||
urlError: none(),
|
||||
anonKeyError: none(),
|
||||
restartApp: false,
|
||||
showRestartHint: config.url.isNotEmpty && config.anon_key.isNotEmpty,
|
||||
config: config,
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user