Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: remove authticator pb

Nathan2f5b49488590
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_view_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_view_page.dart
index 85a5e3cbfa..9706777df0 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_view_page.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/bottom_sheet_view_page.dart
@@ -202,8 +202,7 @@ class MobileViewBottomSheetBody extends StatelessWidget {
List<Widget> _buildPublishActions(BuildContext context) {
final userProfile = context.read<MobileViewPageBloc>().state.userProfilePB;
// the publish feature is only available for AppFlowy Cloud
- if (userProfile == null ||
- userProfile.authType != AuthenticatorPB.AppFlowyCloud) {
+ if (userProfile == null || userProfile.authType != AuthTypePB.Server) {
return [];
}
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/setting/settings_popup_menu.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/setting/settings_popup_menu.dart
index 11a82d2c7a..bd41730934 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/setting/settings_popup_menu.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/setting/settings_popup_menu.dart
@@ -48,7 +48,7 @@ class HomePageSettingsPopupMenu extends StatelessWidget {
text: LocaleKeys.settings_popupMenuItem_settings.tr(),
),
// only show the member items in cloud mode
- if (userProfile.authType == AuthenticatorPB.AppFlowyCloud) ...[
+ if (userProfile.authType == AuthTypePB.Server) ...[
const PopupMenuDivider(height: 0.5),
_buildItem(
value: _MobileSettingsPopupMenuItem.members,
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/tab/mobile_space_tab.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/tab/mobile_space_tab.dart
index cc3f4c8c56..c89367f379 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/tab/mobile_space_tab.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/tab/mobile_space_tab.dart
@@ -167,7 +167,7 @@ class _MobileSpaceTabState extends State<MobileSpaceTab>
children: [
MobileHomeSpace(userProfile: widget.userProfile),
// only show ai chat button for cloud user
- if (widget.userProfile.authType == AuthenticatorPB.AppFlowyCloud)
+ if (widget.userProfile.authType == AuthTypePB.Server)
Positioned(
bottom: MediaQuery.of(context).padding.bottom + 16,
left: 20,
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/workspaces/workspace_menu_bottom_sheet.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/workspaces/workspace_menu_bottom_sheet.dart
index eff2b4f420..d306f48964 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/workspaces/workspace_menu_bottom_sheet.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/workspaces/workspace_menu_bottom_sheet.dart
@@ -123,7 +123,7 @@ class _CreateWorkspaceButton extends StatelessWidget {
context.read<UserWorkspaceBloc>().add(
UserWorkspaceEvent.createWorkspace(
name,
- AuthTypePB.CloudAuthType,
+ AuthTypePB.Server,
),
);
},
diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/user_session_setting_group.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/user_session_setting_group.dart
index 09f38223f4..405fef0d1a 100644
--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/user_session_setting_group.dart
+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/user_session_setting_group.dart
@@ -40,7 +40,7 @@ class UserSessionSettingGroup extends StatelessWidget {
// delete account button
// only show the delete account button in cloud mode
- if (userProfile.authType == AuthenticatorPB.AppFlowyCloud) ...[
+ if (userProfile.authType == AuthTypePB.Server) ...[
const VSpace(16.0),
MobileLogoutButton(
text: LocaleKeys.button_deleteAccount.tr(),
diff --git a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
index c154b0e3a0..90085354db 100644
--- a/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
+++ b/frontend/appflowy_flutter/lib/plugins/ai_chat/chat_page.dart
@@ -48,7 +48,7 @@ class AIChatPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
- // if (userProfile.authenticator != AuthenticatorPB.AppFlowyCloud) {
+ // if (userProfile.authenticator != AuthTypePB.Server) {
// return Center(
// child: FlowyText(
// LocaleKeys.chat_unsupportedCloudPrompt.tr(),
diff --git a/frontend/appflowy_flutter/lib/plugins/database/application/sync/database_sync_bloc.dart b/frontend/appflowy_flutter/lib/plugins/database/application/sync/database_sync_bloc.dart
index 53dc2bd6d5..5116785c1f 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/application/sync/database_sync_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/application/sync/database_sync_bloc.dart
@@ -31,7 +31,7 @@ class DatabaseSyncBloc extends Bloc<DatabaseSyncEvent, DatabaseSyncBlocState> {
emit(
state.copyWith(
shouldShowIndicator:
- userProfile?.authType == AuthenticatorPB.AppFlowyCloud &&
+ userProfile?.authType == AuthTypePB.Server &&
databaseId != null,
),
);
diff --git a/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_banner.dart b/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_banner.dart
index 5706167f1a..e2f470e0d3 100644
--- a/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_banner.dart
+++ b/frontend/appflowy_flutter/lib/plugins/database/widgets/row/row_banner.dart
@@ -21,8 +21,8 @@ import 'package:appflowy/shared/af_image.dart';
import 'package:appflowy/shared/flowy_gradient_colors.dart';
import 'package:appflowy/shared/icon_emoji_picker/flowy_icon_emoji_picker.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
-import 'package:appflowy_backend/protobuf/flowy-user/auth.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
+import 'package:appflowy_backend/protobuf/flowy-user/workspace.pb.dart';
import 'package:appflowy_editor/appflowy_editor.dart' hide UploadImageMenu;
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/theme_extension.dart';
@@ -69,8 +69,7 @@ class RowBanner extends StatefulWidget {
class _RowBannerState extends State<RowBanner> {
final _isHovering = ValueNotifier(false);
late final isLocalMode =
- (widget.userProfile?.authType ?? AuthenticatorPB.Local) ==
- AuthenticatorPB.Local;
+ (widget.userProfile?.authType ?? AuthTypePB.Local) == AuthTypePB.Local;
@override
void dispose() {
diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dart
index 252742aa5e..ac03fe5308 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/application/document_bloc.dart
@@ -101,8 +101,8 @@ class DocumentBloc extends Bloc<DocumentEvent, DocumentState> {
bool get isLocalMode {
final userProfilePB = state.userProfilePB;
- final type = userProfilePB?.authType ?? AuthenticatorPB.Local;
- return type == AuthenticatorPB.Local;
+ final type = userProfilePB?.authType ?? AuthTypePB.Local;
+ return type == AuthTypePB.Local;
}
@override
diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/document_collaborators_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/application/document_collaborators_bloc.dart
index b593ccc6cc..682f600f0a 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/application/document_collaborators_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/application/document_collaborators_bloc.dart
@@ -31,8 +31,7 @@ class DocumentCollaboratorsBloc
final userProfile = result.fold((s) => s, (f) => null);
emit(
state.copyWith(
- shouldShowIndicator:
- userProfile?.authType == AuthenticatorPB.AppFlowyCloud,
+ shouldShowIndicator: userProfile?.authType == AuthTypePB.Server,
),
);
final deviceId = ApplicationInfo.deviceId;
diff --git a/frontend/appflowy_flutter/lib/plugins/document/application/document_sync_bloc.dart b/frontend/appflowy_flutter/lib/plugins/document/application/document_sync_bloc.dart
index 1001aaef5e..2ba50fc6c4 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/application/document_sync_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/application/document_sync_bloc.dart
@@ -30,8 +30,7 @@ class DocumentSyncBloc extends Bloc<DocumentSyncEvent, DocumentSyncBlocState> {
);
emit(
state.copyWith(
- shouldShowIndicator:
- userProfile?.authType == AuthenticatorPB.AppFlowyCloud,
+ shouldShowIndicator: userProfile?.authType == AuthTypePB.Server,
),
);
_syncStateListener.start(
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_util.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_util.dart
index d3bbbd27d5..69791f78b7 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_util.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/file/file_util.dart
@@ -14,8 +14,8 @@ import 'package:appflowy_backend/dispatch/error.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/file_entities.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/media_entities.pb.dart';
-import 'package:appflowy_backend/protobuf/flowy-user/auth.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
+import 'package:appflowy_backend/protobuf/flowy-user/workspace.pb.dart';
import 'package:cross_file/cross_file.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flowy_infra/file_picker/file_picker_impl.dart';
@@ -185,7 +185,7 @@ Future<void> insertLocalFile(
// Check upload type
final isLocalMode =
- (userProfile?.authType ?? AuthenticatorPB.Local) == AuthenticatorPB.Local;
+ (userProfile?.authType ?? AuthTypePB.Local) == AuthTypePB.Local;
String? path;
String? errorMsg;
@@ -230,7 +230,7 @@ Future<void> insertLocalFiles(
// Check upload type
final isLocalMode =
- (userProfile?.authType ?? AuthenticatorPB.Local) == AuthenticatorPB.Local;
+ (userProfile?.authType ?? AuthTypePB.Local) == AuthTypePB.Local;
for (final file in files) {
final fileType = file.fileType.toMediaFileTypePB();
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_cover_image.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_cover_image.dart
index 601ba8fa20..6136392884 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_cover_image.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/page_style/_page_style_cover_image.dart
@@ -225,8 +225,7 @@ class PageStyleCoverImage extends StatelessWidget {
(s) => s,
(f) => null,
);
- final isAppFlowyCloud =
- userProfile?.authType == AuthenticatorPB.AppFlowyCloud;
+ final isAppFlowyCloud = userProfile?.authType == AuthTypePB.Server;
final PageStyleCoverImageType type;
if (!isAppFlowyCloud) {
result = await saveImageToLocalStorage(path);
diff --git a/frontend/appflowy_flutter/lib/plugins/shared/share/share_bloc.dart b/frontend/appflowy_flutter/lib/plugins/shared/share/share_bloc.dart
index c3f04a8837..2356399b4a 100644
--- a/frontend/appflowy_flutter/lib/plugins/shared/share/share_bloc.dart
+++ b/frontend/appflowy_flutter/lib/plugins/shared/share/share_bloc.dart
@@ -193,7 +193,7 @@ class ShareBloc extends Bloc<ShareEvent, ShareState> {
Future<void> _updatePublishStatus(Emitter<ShareState> emit) async {
final publishInfo = await ViewBackendService.getPublishInfo(view);
final enablePublish = await UserBackendService.getCurrentUserProfile().fold(
- (v) => v.authType == AuthenticatorPB.AppFlowyCloud,
+ (v) => v.authType == AuthTypePB.Server,
(p) => false,
);
diff --git a/frontend/appflowy_flutter/lib/shared/icon_emoji_picker/icon_uploader.dart b/frontend/appflowy_flutter/lib/shared/icon_emoji_picker/icon_uploader.dart
index f39fdb01dc..ff8e7b88ec 100644
--- a/frontend/appflowy_flutter/lib/shared/icon_emoji_picker/icon_uploader.dart
+++ b/frontend/appflowy_flutter/lib/shared/icon_emoji_picker/icon_uploader.dart
@@ -13,7 +13,7 @@ import 'package:appflowy/startup/startup.dart';
import 'package:appflowy/user/application/user_service.dart';
import 'package:appflowy/util/default_extensions.dart';
import 'package:appflowy_backend/log.dart';
-import 'package:appflowy_backend/protobuf/flowy-user/auth.pbenum.dart';
+import 'package:appflowy_backend/protobuf/flowy-user/workspace.pb.dart';
import 'package:desktop_drop/desktop_drop.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -294,8 +294,8 @@ class _IconUploaderState extends State<IconUploader> {
(userProfile) => userProfile,
(l) => null,
);
- final isLocalMode = (userProfile?.authType ?? AuthenticatorPB.Local) ==
- AuthenticatorPB.Local;
+ final isLocalMode =
+ (userProfile?.authType ?? AuthTypePB.Local) == AuthTypePB.Local;
if (isLocalMode) {
result = await pickedImages.first.saveToLocal();
} else {
diff --git a/frontend/appflowy_flutter/lib/startup/deps_resolver.dart b/frontend/appflowy_flutter/lib/startup/deps_resolver.dart
index 621ba988cf..5a8c0fa651 100644
--- a/frontend/appflowy_flutter/lib/startup/deps_resolver.dart
+++ b/frontend/appflowy_flutter/lib/startup/deps_resolver.dart
@@ -102,7 +102,7 @@ void _resolveUserDeps(GetIt getIt, IntegrationMode mode) {
case AuthenticatorType.local:
getIt.registerFactory<AuthService>(
() => BackendAuthService(
- AuthenticatorPB.Local,
+ AuthTypePB.Local,
),
);
break;
diff --git a/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart b/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart
index 184cc9dd09..362b27a85a 100644
--- a/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart
+++ b/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart
@@ -112,7 +112,7 @@ class AppFlowyCloudDeepLink {
(_) async {
final deviceId = await getDeviceId();
final payload = OauthSignInPB(
- authenticator: AuthenticatorPB.AppFlowyCloud,
+ authenticator: AuthTypePB.Server,
map: {
AuthServiceMapKeys.signInURL: uri.toString(),
AuthServiceMapKeys.deviceId: deviceId,
diff --git a/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart b/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart
index 6d02f188c8..4f4cece9bb 100644
--- a/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart
+++ b/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_auth_service.dart
@@ -18,7 +18,7 @@ class AppFlowyCloudAuthService implements AuthService {
AppFlowyCloudAuthService();
final BackendAuthService _backendAuthService = BackendAuthService(
- AuthenticatorPB.AppFlowyCloud,
+ AuthTypePB.Server,
);
@override
diff --git a/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_mock_auth_service.dart b/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_mock_auth_service.dart
index d8cee89b59..8be71dc648 100644
--- a/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_mock_auth_service.dart
+++ b/frontend/appflowy_flutter/lib/user/application/auth/af_cloud_mock_auth_service.dart
@@ -20,7 +20,7 @@ class AppFlowyCloudMockAuthService implements AuthService {
final String userEmail;
final BackendAuthService _appFlowyAuthService =
- BackendAuthService(AuthenticatorPB.AppFlowyCloud);
+ BackendAuthService(AuthTypePB.Server);
@override
Future<FlowyResult<UserProfilePB, FlowyError>> signUp({
@@ -48,7 +48,7 @@ class AppFlowyCloudMockAuthService implements AuthService {
Map<String, String> params = const {},
}) async {
final payload = SignInUrlPayloadPB.create()
- ..authenticator = AuthenticatorPB.AppFlowyCloud
+ ..authenticator = AuthTypePB.Server
// don't use nanoid here, the gotrue server will transform the email
..email = userEmail;
@@ -58,7 +58,7 @@ class AppFlowyCloudMockAuthService implements AuthService {
return getSignInURLResult.fold(
(urlPB) async {
final payload = OauthSignInPB(
- authenticator: AuthenticatorPB.AppFlowyCloud,
+ authenticator: AuthTypePB.Server,
map: {
AuthServiceMapKeys.signInURL: urlPB.signInUrl,
AuthServiceMapKeys.deviceId: deviceId,
diff --git a/frontend/appflowy_flutter/lib/user/application/auth/backend_auth_service.dart b/frontend/appflowy_flutter/lib/user/application/auth/backend_auth_service.dart
index f47fd5a4a6..cab8cd170c 100644
--- a/frontend/appflowy_flutter/lib/user/application/auth/backend_auth_service.dart
+++ b/frontend/appflowy_flutter/lib/user/application/auth/backend_auth_service.dart
@@ -6,6 +6,7 @@ import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/auth.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart'
show SignInPayloadPB, SignUpPayloadPB, UserProfilePB;
+import 'package:appflowy_backend/protobuf/flowy-user/workspace.pb.dart';
import 'package:appflowy_result/appflowy_result.dart';
import 'package:easy_localization/easy_localization.dart';
@@ -15,7 +16,7 @@ import 'device_id.dart';
class BackendAuthService implements AuthService {
BackendAuthService(this.authType);
- final AuthenticatorPB authType;
+ final AuthTypePB authType;
@override
Future<FlowyResult<GotrueTokenResponsePB, FlowyError>>
@@ -71,7 +72,7 @@ class BackendAuthService implements AuthService {
..email = userEmail
..password = password
// When sign up as guest, the auth type is always local.
- ..authType = AuthenticatorPB.Local
+ ..authType = AuthTypePB.Local
..deviceId = await getDeviceId();
final response = await UserEventSignUp(request).send().then(
(value) => value,
@@ -82,7 +83,7 @@ class BackendAuthService implements AuthService {
@override
Future<FlowyResult<UserProfilePB, FlowyError>> signUpWithOAuth({
required String platform,
- AuthenticatorPB authType = AuthenticatorPB.Local,
+ AuthTypePB authType = AuthTypePB.Local,
Map<String, String> params = const {},
}) async {
return FlowyResult.failure(
diff --git a/frontend/appflowy_flutter/lib/user/application/password/password_bloc.dart b/frontend/appflowy_flutter/lib/user/application/password/password_bloc.dart
index d421440d08..b85efe38ae 100644
--- a/frontend/appflowy_flutter/lib/user/application/password/password_bloc.dart
+++ b/frontend/appflowy_flutter/lib/user/application/password/password_bloc.dart
@@ -4,8 +4,8 @@ import 'package:appflowy/env/cloud_env.dart';
import 'package:appflowy/user/application/password/password_http_service.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
-import 'package:appflowy_backend/protobuf/flowy-user/auth.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
+import 'package:appflowy_backend/protobuf/flowy-user/workspace.pb.dart';
import 'package:appflowy_result/appflowy_result.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
@@ -46,7 +46,7 @@ class PasswordBloc extends Bloc<PasswordEvent, PasswordState> {
bool _isInitialized = false;
Future<void> _init() async {
- if (userProfile.authType == AuthenticatorPB.Local) {
+ if (userProfile.authType == AuthTypePB.Local) {
Log.debug('PasswordBloc: skip init because user is local authenticator');
return;
}
diff --git a/frontend/appflowy_flutter/lib/user/presentation/anon_user.dart b/frontend/appflowy_flutter/lib/user/presentation/anon_user.dart
index 014c7caaf8..c8744fb304 100644
--- a/frontend/appflowy_flutter/lib/user/presentation/anon_user.dart
+++ b/frontend/appflowy_flutter/lib/user/presentation/anon_user.dart
@@ -74,7 +74,7 @@ class AnonUserItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final icon = isSelected ? const FlowySvg(FlowySvgs.check_s) : null;
- final isDisabled = isSelected || user.authType != AuthenticatorPB.Local;
+ final isDisabled = isSelected || user.authType != AuthTypePB.Local;
final desc = "${user.name}\t ${user.authType}\t";
final child = SizedBox(
height: 30,
diff --git a/frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart
index 66277cf30b..ce659d5262 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/settings/settings_dialog_bloc.dart
@@ -2,8 +2,6 @@ import 'package:appflowy/user/application/user_listener.dart';
import 'package:appflowy_backend/dispatch/dispatch.dart';
import 'package:appflowy_backend/log.dart';
import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';
-import 'package:appflowy_backend/protobuf/flowy-user/auth.pbenum.dart';
-import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
import 'package:appflowy_backend/protobuf/flowy-user/workspace.pb.dart';
import 'package:appflowy_result/appflowy_result.dart';
import 'package:flutter/foundation.dart';
@@ -91,7 +89,7 @@ class SettingsDialogBloc
AFRolePB? currentWorkspaceMemberRole,
]) async {
if ([
- AuthenticatorPB.Local,
+ AuthTypePB.Local,
].contains(userProfile.authType)) {
return false;
}
diff --git a/frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart
index 44e9fa3f92..5ed56b890e 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/user/user_workspace_bloc.dart
@@ -44,7 +44,7 @@ class UserWorkspaceBloc extends Bloc<UserWorkspaceEvent, UserWorkspaceState> {
final currentWorkspace = result.$1;
final workspaces = result.$2;
final isCollabWorkspaceOn =
- userProfile.authType == AuthenticatorPB.AppFlowyCloud &&
+ userProfile.authType == AuthTypePB.Server &&
FeatureFlag.collaborativeWorkspace.isOn;
Log.info(
'init workspace, current workspace: ${currentWorkspace?.workspaceId}, '
diff --git a/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_bloc.dart b/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_bloc.dart
index 0db1ac9443..ed06f16c8f 100644
--- a/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_bloc.dart
+++ b/frontend/appflowy_flutter/lib/workspace/application/workspace/workspace_bloc.dart
@@ -66,7 +66,7 @@ class WorkspaceBloc extends Bloc<WorkspaceEvent, WorkspaceState> {
Emitter<WorkspaceState> emit,
) async {
final result =
- await userService.createUserWorkspace(name, AuthTypePB.CloudAuthType);
+ await userService.createUserWorkspace(name, AuthTypePB.Server);
emit(
result.fold(
(workspace) {
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart
index 24a122fee5..c9f464d43a 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart
@@ -389,7 +389,7 @@ class _CreateWorkspaceButton extends StatelessWidget {
workspaceBloc.add(
UserWorkspaceEvent.createWorkspace(
name,
- AuthTypePB.CloudAuthType,
+ AuthTypePB.Local,
),
);
},
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_more_action_button.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_more_action_button.dart
index 576ff07cb4..7ccd03b4f4 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_more_action_button.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_more_action_button.dart
@@ -211,7 +211,7 @@ class ViewMoreActionTypeWrapper extends CustomActionCell {
) {
final userProfile = context.read<SpaceBloc>().userProfile;
// move to feature doesn't support in local mode
- if (userProfile.authType != AuthenticatorPB.AppFlowyCloud) {
+ if (userProfile.authType != AuthTypePB.Server) {
return const SizedBox.shrink();
}
return BlocProvider.value(
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_account_view.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_account_view.dart
index f1ecfda8ad..e242da473b 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_account_view.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_account_view.dart
@@ -7,8 +7,8 @@ import 'package:appflowy/workspace/presentation/settings/pages/account/account.d
import 'package:appflowy/workspace/presentation/settings/pages/account/email/email_section.dart';
import 'package:appflowy/workspace/presentation/settings/shared/settings_body.dart';
import 'package:appflowy/workspace/presentation/settings/shared/settings_category.dart';
-import 'package:appflowy_backend/protobuf/flowy-user/auth.pbenum.dart';
import 'package:appflowy_backend/protobuf/flowy-user/user_profile.pb.dart';
+import 'package:appflowy_backend/protobuf/flowy-user/workspace.pb.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -70,7 +70,7 @@ class _SettingsAccountViewState extends State<SettingsAccountView> {
// user email
// Only show email if the user is authenticated and not using local auth
if (isAuthEnabled &&
- state.userProfile.authType != AuthenticatorPB.Local) ...[
+ state.userProfile.authType != AuthTypePB.Local) ...[
SettingsCategory(
title: LocaleKeys.newSettings_myAccount_myAccount.tr(),
children: [
@@ -82,30 +82,26 @@ class _SettingsAccountViewState extends State<SettingsAccountView> {
),
AccountSignInOutSection(
userProfile: state.userProfile,
- onAction:
- state.userProfile.authType == AuthenticatorPB.Local
- ? widget.didLogin
- : widget.didLogout,
- signIn:
- state.userProfile.authType == AuthenticatorPB.Local,
+ onAction: state.userProfile.authType == AuthTypePB.Local
+ ? widget.didLogin
+ : widget.didLogout,
+ signIn: state.userProfile.authType == AuthTypePB.Local,
),
],
),
],
if (isAuthEnabled &&
- state.userProfile.authType == AuthenticatorPB.Local) ...[
+ state.userProfile.authType == AuthTypePB.Local) ...[
SettingsCategory(
title: LocaleKeys.settings_accountPage_login_title.tr(),
children: [
AccountSignInOutSection(
userProfile: state.userProfile,
- onAction:
- state.userProfile.authType == AuthenticatorPB.Local
- ? widget.didLogin
- : widget.didLogout,
- signIn:
- state.userProfile.authType == AuthenticatorPB.Local,
+ onAction: state.userProfile.authType == AuthTypePB.Local
+ ? widget.didLogin
+ : widget.didLogout,
+ signIn: state.userProfile.authType == AuthTypePB.Local,
),
],
),
@@ -120,7 +116,7 @@ class _SettingsAccountViewState extends State<SettingsAccountView> {
),
// user deletion
- if (widget.userProfile.authType == AuthenticatorPB.AppFlowyCloud)
+ if (widget.userProfile.authType == AuthTypePB.Server)
const AccountDeletionButton(),
],
);
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_workspace_view.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_workspace_view.dart
index a602849527..9a17016e5f 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_workspace_view.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/settings_workspace_view.dart
@@ -88,7 +88,7 @@ class SettingsWorkspaceView extends StatelessWidget {
autoSeparate: false,
children: [
// We don't allow changing workspace name/icon for local/offline
- if (userProfile.authType != AuthenticatorPB.Local) ...[
+ if (userProfile.authType != AuthTypePB.Local) ...[
SettingsCategory(
title: LocaleKeys.settings_workspacePage_workspaceName_title
.tr(),
@@ -180,7 +180,7 @@ class SettingsWorkspaceView extends StatelessWidget {
),
const SettingsCategorySpacer(),
- if (userProfile.authType != AuthenticatorPB.Local) ...[
+ if (userProfile.authType != AuthTypePB.Local) ...[
SingleSettingAction(
label: LocaleKeys.settings_workspacePage_manageWorkspace_title
.tr(),
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart
index b17a9beb7e..e262a27cb6 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/settings_dialog.dart
@@ -140,7 +140,7 @@ class SettingsDialog extends StatelessWidget {
case SettingsPage.shortcuts:
return const SettingsShortcutsView();
case SettingsPage.ai:
- if (user.authType == AuthenticatorPB.AppFlowyCloud) {
+ if (user.authType == AuthTypePB.Server) {
return SettingsAIView(
key: ValueKey(workspaceId),
userProfile: user,
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_menu.dart
index 1a7144993f..04a93656ca 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_menu.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/settings_menu.dart
@@ -63,7 +63,7 @@ class SettingsMenu extends StatelessWidget {
changeSelectedPage: changeSelectedPage,
),
if (FeatureFlag.membersSettings.isOn &&
- userProfile.authType == AuthenticatorPB.AppFlowyCloud)
+ userProfile.authType == AuthTypePB.Server)
SettingsMenuElement(
page: SettingsPage.member,
selectedPage: currentPage,
@@ -109,7 +109,7 @@ class SettingsMenu extends StatelessWidget {
),
changeSelectedPage: changeSelectedPage,
),
- if (userProfile.authType == AuthenticatorPB.AppFlowyCloud)
+ if (userProfile.authType == AuthTypePB.Server)
SettingsMenuElement(
page: SettingsPage.sites,
selectedPage: currentPage,
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dart b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dart
index 3b81d2a041..fe202e7590 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/widgets/more_view_actions/more_view_actions.dart
@@ -96,7 +96,7 @@ class _MoreViewActionsState extends State<MoreViewActions> {
return BlocBuilder<SpaceBloc, SpaceState>(
builder: (context, state) {
if (state.spaces.isEmpty &&
- userProfile.authType == AuthenticatorPB.AppFlowyCloud) {
+ userProfile.authType == AuthTypePB.Server) {
return const SizedBox.shrink();
}
diff --git a/frontend/rust-lib/event-integration-test/src/lib.rs b/frontend/rust-lib/event-integration-test/src/lib.rs
index 1b54087ee1..ff0a3847df 100644
--- a/frontend/rust-lib/event-integration-test/src/lib.rs
+++ b/frontend/rust-lib/event-integration-test/src/lib.rs
@@ -8,7 +8,7 @@ use collab_entity::CollabType;
use flowy_core::config::AppFlowyCoreConfig;
use flowy_core::AppFlowyCore;
use flowy_notification::register_notification_sender;
-use flowy_user::entities::AuthenticatorPB;
+use flowy_user::entities::AuthTypePB;
use flowy_user::errors::FlowyError;
use lib_dispatch::runtime::AFPluginRuntime;
use nanoid::nanoid;
@@ -59,7 +59,7 @@ impl EventIntegrationTest {
let clean_path = config.storage_path.clone();
let inner = init_core(config).await;
let notification_sender = TestNotificationSender::new();
- let authenticator = Arc::new(AtomicU8::new(AuthenticatorPB::Local as u8));
+ let authenticator = Arc::new(AtomicU8::new(AuthTypePB::Local as u8));
register_notification_sender(notification_sender.clone());
// In case of dropping the runtime that runs the core, we need to forget the dispatcher
diff --git a/frontend/rust-lib/event-integration-test/src/user_event.rs b/frontend/rust-lib/event-integration-test/src/user_event.rs
index 5c9be65660..c4e34f27f7 100644
--- a/frontend/rust-lib/event-integration-test/src/user_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/user_event.rs
@@ -17,7 +17,7 @@ use flowy_server::af_cloud::define::{USER_DEVICE_ID, USER_EMAIL, USER_SIGN_IN_UR
use flowy_server_pub::af_cloud_config::AFCloudConfiguration;
use flowy_server_pub::AuthenticatorType;
use flowy_user::entities::{
- AuthTypePB, AuthenticatorPB, ChangeWorkspaceIconPB, CloudSettingPB, CreateWorkspacePB,
+ AuthTypePB, AuthTypePB, ChangeWorkspaceIconPB, CloudSettingPB, CreateWorkspacePB,
ImportAppFlowyDataPB, OauthSignInPB, OpenUserWorkspacePB, RenameWorkspacePB,
RepeatedUserWorkspacePB, SignInUrlPB, SignInUrlPayloadPB, SignUpPayloadPB, UpdateCloudConfigPB,
UpdateUserProfilePayloadPB, UserProfilePB, UserWorkspaceIdPB, UserWorkspacePB,
@@ -65,7 +65,7 @@ impl EventIntegrationTest {
email,
name: "appflowy".to_string(),
password: password.clone(),
- auth_type: AuthenticatorPB::Local,
+ auth_type: AuthTypePB::Local,
device_id: uuid::Uuid::new_v4().to_string(),
}
.into_bytes()
@@ -113,7 +113,7 @@ impl EventIntegrationTest {
.await;
}
- pub fn set_auth_type(&self, auth_type: AuthenticatorPB) {
+ pub fn set_auth_type(&self, auth_type: AuthTypePB) {
self.authenticator.store(auth_type as u8, Ordering::Release);
}
@@ -140,7 +140,7 @@ impl EventIntegrationTest {
pub async fn af_cloud_sign_in_with_email(&self, email: &str) -> FlowyResult<UserProfilePB> {
let payload = SignInUrlPayloadPB {
email: email.to_string(),
- authenticator: AuthenticatorPB::AppFlowyCloud,
+ authenticator: AuthTypePB::AppFlowyCloud,
};
let sign_in_url = EventBuilder::new(self.clone())
.event(UserEvent::GenerateSignInURL)
@@ -155,7 +155,7 @@ impl EventIntegrationTest {
map.insert(USER_DEVICE_ID.to_string(), Uuid::new_v4().to_string());
let payload = OauthSignInPB {
map,
- authenticator: AuthenticatorPB::AppFlowyCloud,
+ authenticator: AuthTypePB::AppFlowyCloud,
};
let user_profile = EventBuilder::new(self.clone())
diff --git a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/anon_user_test.rs b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/anon_user_test.rs
index f74b202860..1abdde509f 100644
--- a/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/anon_user_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/user/af_cloud_test/anon_user_test.rs
@@ -1,7 +1,7 @@
use event_integration_test::user_event::use_localhost_af_cloud;
use event_integration_test::EventIntegrationTest;
use flowy_core::DEFAULT_NAME;
-use flowy_user::entities::AuthenticatorPB;
+use flowy_user::entities::AuthTypePB;
use crate::util::unzip;
@@ -72,7 +72,7 @@ async fn migrate_anon_user_data_to_af_cloud_test() {
let user = test.af_cloud_sign_up().await;
let workspace = test.get_current_workspace().await;
println!("user workspace: {:?}", workspace.id);
- assert_eq!(user.auth_type, AuthenticatorPB::AppFlowyCloud);
+ assert_eq!(user.auth_type, AuthTypePB::AppFlowyCloud);
let user_first_level_views = test.get_all_workspace_views().await;
assert_eq!(user_first_level_views.len(), 3);
diff --git a/frontend/rust-lib/event-integration-test/tests/user/local_test/auth_test.rs b/frontend/rust-lib/event-integration-test/tests/user/local_test/auth_test.rs
index 3c73fd01eb..138f6f0258 100644
--- a/frontend/rust-lib/event-integration-test/tests/user/local_test/auth_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/user/local_test/auth_test.rs
@@ -1,6 +1,6 @@
use event_integration_test::user_event::{login_password, unique_email};
use event_integration_test::{event_builder::EventBuilder, EventIntegrationTest};
-use flowy_user::entities::{AuthenticatorPB, SignInPayloadPB, SignUpPayloadPB};
+use flowy_user::entities::{AuthTypePB, SignInPayloadPB, SignUpPayloadPB};
use flowy_user::errors::ErrorCode;
use flowy_user::event_map::UserEvent::*;
@@ -14,7 +14,7 @@ async fn sign_up_with_invalid_email() {
email: email.to_string(),
name: valid_name(),
password: login_password(),
- auth_type: AuthenticatorPB::Local,
+ auth_type: AuthTypePB::Local,
device_id: "".to_string(),
};
@@ -40,7 +40,7 @@ async fn sign_in_with_invalid_email() {
email: email.to_string(),
password: login_password(),
name: "".to_string(),
- auth_type: AuthenticatorPB::Local,
+ auth_type: AuthTypePB::Local,
device_id: "".to_string(),
};
@@ -67,7 +67,7 @@ async fn sign_in_with_invalid_password() {
email: unique_email(),
password,
name: "".to_string(),
- auth_type: AuthenticatorPB::Local,
+ auth_type: AuthTypePB::Local,
device_id: "".to_string(),
};
diff --git a/frontend/rust-lib/event-integration-test/tests/user/local_test/user_profile_test.rs b/frontend/rust-lib/event-integration-test/tests/user/local_test/user_profile_test.rs
index 46f8eca9c6..47c2d53a6b 100644
--- a/frontend/rust-lib/event-integration-test/tests/user/local_test/user_profile_test.rs
+++ b/frontend/rust-lib/event-integration-test/tests/user/local_test/user_profile_test.rs
@@ -1,6 +1,6 @@
use crate::user::local_test::helper::*;
use event_integration_test::{event_builder::EventBuilder, EventIntegrationTest};
-use flowy_user::entities::{AuthenticatorPB, UpdateUserProfilePayloadPB, UserProfilePB};
+use flowy_user::entities::{AuthTypePB, UpdateUserProfilePayloadPB, UserProfilePB};
use flowy_user::{errors::ErrorCode, event_map::UserEvent::*};
use nanoid::nanoid;
#[tokio::test]
@@ -24,7 +24,7 @@ async fn anon_user_profile_get() {
.await
.parse::<UserProfilePB>();
assert_eq!(user_profile.id, user.id);
- assert_eq!(user_profile.auth_type, AuthenticatorPB::Local);
+ assert_eq!(user_profile.auth_type, AuthTypePB::Local);
}
#[tokio::test]
diff --git a/frontend/rust-lib/flowy-server/src/local_server/impls/user.rs b/frontend/rust-lib/flowy-server/src/local_server/impls/user.rs
index eec50b1480..14d39690f9 100644
--- a/frontend/rust-lib/flowy-server/src/local_server/impls/user.rs
+++ b/frontend/rust-lib/flowy-server/src/local_server/impls/user.rs
@@ -35,7 +35,7 @@ impl UserCloudService for LocalServerUserServiceImpl {
let params = params.unbox_or_error::<SignUpParams>()?;
let uid = ID_GEN.lock().await.next_id();
let workspace_id = Uuid::new_v4().to_string();
- let user_workspace = UserWorkspace::new_local(&workspace_id, uid);
+ let user_workspace = UserWorkspace::new_local(workspace_id, "");
let user_name = if params.name.is_empty() {
DEFAULT_USER_NAME()
} else {
@@ -59,7 +59,9 @@ impl UserCloudService for LocalServerUserServiceImpl {
async fn sign_in(&self, params: BoxAny) -> Result<AuthResponse, FlowyError> {
let params: SignInParams = params.unbox_or_error::<SignInParams>()?;
let uid = ID_GEN.lock().await.next_id();
- let user_workspace = make_user_workspace("My Workspace");
+
+ let workspace_id = Uuid::new_v4();
+ let user_workspace = UserWorkspace::new_local(workspace_id.to_string(), "My Workspace");
Ok(AuthResponse {
user_id: uid,
user_uuid: Uuid::new_v4(),
@@ -143,7 +145,11 @@ impl UserCloudService for LocalServerUserServiceImpl {
}
async fn create_workspace(&self, workspace_name: &str) -> Result<UserWorkspace, FlowyError> {
- Ok(make_user_workspace(workspace_name))
+ let workspace_id = Uuid::new_v4();
+ Ok(UserWorkspace::new_local(
+ workspace_id.to_string(),
+ workspace_name,
+ ))
}
async fn patch_workspace(
@@ -192,15 +198,3 @@ impl UserCloudService for LocalServerUserServiceImpl {
Ok(())
}
}
-
-fn make_user_workspace(name: &str) -> UserWorkspace {
- UserWorkspace {
- id: Uuid::new_v4().to_string(),
- name: name.to_string(),
- created_at: Default::default(),
- workspace_database_id: Uuid::new_v4().to_string(),
- icon: "".to_string(),
- member_count: 1,
- role: None,
- }
-}
diff --git a/frontend/rust-lib/flowy-user-pub/src/entities.rs b/frontend/rust-lib/flowy-user-pub/src/entities.rs
index 0d91f84b0e..efceb8b5f6 100644
--- a/frontend/rust-lib/flowy-user-pub/src/entities.rs
+++ b/frontend/rust-lib/flowy-user-pub/src/entities.rs
@@ -122,10 +122,10 @@ impl UserWorkspace {
Ok(id)
}
- pub fn new_local(workspace_id: &str, _uid: i64) -> Self {
+ pub fn new_local(workspace_id: String, name: &str) -> Self {
Self {
- id: workspace_id.to_string(),
- name: "".to_string(),
+ id: workspace_id,
+ name: name.to_string(),
created_at: Utc::now(),
workspace_database_id: Uuid::new_v4().to_string(),
icon: "".to_string(),
diff --git a/frontend/rust-lib/flowy-user-pub/src/sql/workspace_sql.rs b/frontend/rust-lib/flowy-user-pub/src/sql/workspace_sql.rs
index a1165c9621..0570020716 100644
--- a/frontend/rust-lib/flowy-user-pub/src/sql/workspace_sql.rs
+++ b/frontend/rust-lib/flowy-user-pub/src/sql/workspace_sql.rs
@@ -93,20 +93,20 @@ pub fn upsert_user_workspace(
user_workspace: UserWorkspace,
conn: &mut SqliteConnection,
) -> Result<(), FlowyError> {
- let new_record = UserWorkspaceTable::from_workspace(uid, &user_workspace, auth_type)?;
+ let row = UserWorkspaceTable::from_workspace(uid, &user_workspace, auth_type)?;
diesel::insert_into(user_workspace_table::table)
- .values(new_record.clone())
+ .values(row.clone())
.on_conflict(user_workspace_table::id)
.do_update()
.set((
- user_workspace_table::name.eq(new_record.name),
- user_workspace_table::uid.eq(new_record.uid),
- user_workspace_table::created_at.eq(new_record.created_at),
- user_workspace_table::database_storage_id.eq(new_record.database_storage_id),
- user_workspace_table::icon.eq(new_record.icon),
- user_workspace_table::member_count.eq(new_record.member_count),
- user_workspace_table::role.eq(new_record.role),
- user_workspace_table::auth_type.eq(new_record.auth_type),
+ user_workspace_table::name.eq(row.name),
+ user_workspace_table::uid.eq(row.uid),
+ user_workspace_table::created_at.eq(row.created_at),
+ user_workspace_table::database_storage_id.eq(row.database_storage_id),
+ user_workspace_table::icon.eq(row.icon),
+ user_workspace_table::member_count.eq(row.member_count),
+ user_workspace_table::role.eq(row.role),
+ user_workspace_table::auth_type.eq(row.auth_type),
))
.execute(conn)?;
diff --git a/frontend/rust-lib/flowy-user/src/entities/auth.rs b/frontend/rust-lib/flowy-user/src/entities/auth.rs
index ddc0dc29f9..a61ba5cc96 100644
--- a/frontend/rust-lib/flowy-user/src/entities/auth.rs
+++ b/frontend/rust-lib/flowy-user/src/entities/auth.rs
@@ -1,13 +1,13 @@
use std::collections::HashMap;
use std::convert::TryInto;
+use crate::entities::parser::*;
+use crate::entities::AuthTypePB;
+use crate::errors::ErrorCode;
use client_api::entity::GotrueTokenResponse;
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use flowy_user_pub::entities::*;
-use crate::entities::parser::*;
-use crate::errors::ErrorCode;
-
#[derive(ProtoBuf, Default)]
pub struct SignInPayloadPB {
#[pb(index = 1)]
@@ -20,7 +20,7 @@ pub struct SignInPayloadPB {
pub name: String,
#[pb(index = 4)]
- pub auth_type: AuthenticatorPB,
+ pub auth_type: AuthTypePB,
#[pb(index = 5)]
pub device_id: String,
@@ -53,7 +53,7 @@ pub struct SignUpPayloadPB {
pub password: String,
#[pb(index = 4)]
- pub auth_type: AuthenticatorPB,
+ pub auth_type: AuthTypePB,
#[pb(index = 5)]
pub device_id: String,
@@ -144,7 +144,7 @@ pub struct OauthSignInPB {
pub map: HashMap<String, String>,
#[pb(index = 2)]
- pub authenticator: AuthenticatorPB,
+ pub authenticator: AuthTypePB,
}
#[derive(ProtoBuf, Default)]
@@ -153,7 +153,7 @@ pub struct SignInUrlPayloadPB {
pub email: String,
#[pb(index = 2)]
- pub authenticator: AuthenticatorPB,
+ pub authenticator: AuthTypePB,
}
#[derive(ProtoBuf, Default)]
@@ -228,41 +228,10 @@ pub struct OauthProviderDataPB {
pub oauth_url: String,
}
-#[repr(u8)]
-#[derive(ProtoBuf_Enum, Eq, PartialEq, Debug, Clone)]
-pub enum AuthenticatorPB {
- Local = 0,
- AppFlowyCloud = 2,
-}
-
-impl From<AuthType> for AuthenticatorPB {
- fn from(auth_type: AuthType) -> Self {
- match auth_type {
- AuthType::Local => AuthenticatorPB::Local,
- AuthType::AppFlowyCloud => AuthenticatorPB::AppFlowyCloud,
- }
- }
-}
-
-impl From<AuthenticatorPB> for AuthType {
- fn from(pb: AuthenticatorPB) -> Self {
- match pb {
- AuthenticatorPB::Local => AuthType::Local,
- AuthenticatorPB::AppFlowyCloud => AuthType::AppFlowyCloud,
- }
- }
-}
-
-impl Default for AuthenticatorPB {
- fn default() -> Self {
- Self::Local
- }
-}
-
#[derive(Default, ProtoBuf)]
pub struct UserStatePB {
#[pb(index = 1)]
- pub auth_type: AuthenticatorPB,
+ pub auth_type: AuthTypePB,
}
#[derive(ProtoBuf, Debug, Default, Clone)]
diff --git a/frontend/rust-lib/flowy-user/src/entities/user_profile.rs b/frontend/rust-lib/flowy-user/src/entities/user_profile.rs
index 17b951bae0..5afc93850a 100644
--- a/frontend/rust-lib/flowy-user/src/entities/user_profile.rs
+++ b/frontend/rust-lib/flowy-user/src/entities/user_profile.rs
@@ -1,6 +1,6 @@
use super::AFRolePB;
use crate::entities::parser::{UserEmail, UserIcon, UserName};
-use crate::entities::{AuthTypePB, AuthenticatorPB};
+use crate::entities::AuthTypePB;
use crate::errors::ErrorCode;
use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
use flowy_user_pub::entities::*;
@@ -39,7 +39,7 @@ pub struct UserProfilePB {
pub icon_url: String,
#[pb(index = 6)]
- pub auth_type: AuthenticatorPB,
+ pub auth_type: AuthTypePB,
}
#[derive(ProtoBuf_Enum, Eq, PartialEq, Debug, Clone)]
diff --git a/frontend/rust-lib/flowy-user/src/entities/workspace.rs b/frontend/rust-lib/flowy-user/src/entities/workspace.rs
index e178b724db..ed8eb8aa76 100644
--- a/frontend/rust-lib/flowy-user/src/entities/workspace.rs
+++ b/frontend/rust-lib/flowy-user/src/entities/workspace.rs
@@ -242,18 +242,23 @@ pub struct CreateWorkspacePB {
pub auth_type: AuthTypePB,
}
-#[derive(ProtoBuf_Enum, Default, Debug, Clone)]
+#[derive(ProtoBuf_Enum, Default, Debug, Clone, Eq, PartialEq)]
+#[repr(u8)]
pub enum AuthTypePB {
- LocalAuthType = 0,
#[default]
- CloudAuthType = 1,
+ Local = 0,
+ Server = 1,
}
+
impl From<i32> for AuthTypePB {
fn from(value: i32) -> Self {
match value {
- 0 => AuthTypePB::LocalAuthType,
- 1 => AuthTypePB::CloudAuthType,
- _ => AuthTypePB::CloudAuthType,
+ 0 => AuthTypePB::Local,
+ 1 => AuthTypePB::Server,
+ // For historical reasons, 2 also maps to Server.
+ // Check the AuthenticatorType in flowy-server-pub
+ 2 => AuthTypePB::Server,
+ _ => AuthTypePB::Server,
}
}
}
@@ -261,8 +266,8 @@ impl From<i32> for AuthTypePB {
impl From<AuthType> for AuthTypePB {
fn from(value: AuthType) -> Self {
match value {
- AuthType::Local => AuthTypePB::LocalAuthType,
- AuthType::AppFlowyCloud => AuthTypePB::CloudAuthType,
+ AuthType::Local => AuthTypePB::Local,
+ AuthType::AppFlowyCloud => AuthTypePB::Server,
}
}
}
@@ -270,8 +275,8 @@ impl From<AuthType> for AuthTypePB {
impl From<AuthTypePB> for AuthType {
fn from(value: AuthTypePB) -> Self {
match value {
- AuthTypePB::LocalAuthType => AuthType::Local,
- AuthTypePB::CloudAuthType => AuthType::AppFlowyCloud,
+ AuthTypePB::Local => AuthType::Local,
+ AuthTypePB::Server => AuthType::AppFlowyCloud,
}
}
}
diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs
index 17565e83df..6c786d9435 100644
--- a/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs
+++ b/frontend/rust-lib/flowy-user/src/user_manager/manager_user_workspace.rs
@@ -218,15 +218,23 @@ impl UserManager {
workspace_name: &str,
auth_type: AuthType,
) -> FlowyResult<UserWorkspace> {
- let new_workspace = self
- .cloud_service
- .get_user_service()?
- .create_workspace(workspace_name)
- .await?;
+ let new_workspace = match auth_type {
+ AuthType::Local => {
+ let workspace_id = Uuid::new_v4();
+ UserWorkspace::new_local(workspace_id.to_string(), workspace_name)
+ },
+ AuthType::AppFlowyCloud => {
+ self
+ .cloud_service
+ .get_user_service()?
+ .create_workspace(workspace_name)
+ .await?
+ },
+ };
info!(
- "new workspace: {}, name:{}",
- new_workspace.id, new_workspace.name
+ "create workspace: {}, name:{}, auth_type: {}",
+ new_workspace.id, new_workspace.name, auth_type
);
// save the workspace to sqlite db