mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-11-02 11:04:02 +00:00
chore: remove authticator pb
This commit is contained in:
parent
58f87b39aa
commit
2f5b494885
@ -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 [];
|
||||
}
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -123,7 +123,7 @@ class _CreateWorkspaceButton extends StatelessWidget {
|
||||
context.read<UserWorkspaceBloc>().add(
|
||||
UserWorkspaceEvent.createWorkspace(
|
||||
name,
|
||||
AuthTypePB.CloudAuthType,
|
||||
AuthTypePB.Server,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -31,7 +31,7 @@ class DatabaseSyncBloc extends Bloc<DatabaseSyncEvent, DatabaseSyncBlocState> {
|
||||
emit(
|
||||
state.copyWith(
|
||||
shouldShowIndicator:
|
||||
userProfile?.authType == AuthenticatorPB.AppFlowyCloud &&
|
||||
userProfile?.authType == AuthTypePB.Server &&
|
||||
databaseId != null,
|
||||
),
|
||||
);
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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,
|
||||
);
|
||||
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -102,7 +102,7 @@ void _resolveUserDeps(GetIt getIt, IntegrationMode mode) {
|
||||
case AuthenticatorType.local:
|
||||
getIt.registerFactory<AuthService>(
|
||||
() => BackendAuthService(
|
||||
AuthenticatorPB.Local,
|
||||
AuthTypePB.Local,
|
||||
),
|
||||
);
|
||||
break;
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -18,7 +18,7 @@ class AppFlowyCloudAuthService implements AuthService {
|
||||
AppFlowyCloudAuthService();
|
||||
|
||||
final BackendAuthService _backendAuthService = BackendAuthService(
|
||||
AuthenticatorPB.AppFlowyCloud,
|
||||
AuthTypePB.Server,
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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}, '
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -389,7 +389,7 @@ class _CreateWorkspaceButton extends StatelessWidget {
|
||||
workspaceBloc.add(
|
||||
UserWorkspaceEvent.createWorkspace(
|
||||
name,
|
||||
AuthTypePB.CloudAuthType,
|
||||
AuthTypePB.Local,
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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(),
|
||||
],
|
||||
);
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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(),
|
||||
};
|
||||
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
|
||||
@ -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)?;
|
||||
|
||||
|
||||
@ -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)]
|
||||
|
||||
@ -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)]
|
||||
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user