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: use auth type instead of workspace auth type

Nathan718c5ad16f51
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 05d0f1cbd2..081a7672ae 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
@@ -42,7 +42,7 @@ class UserSessionSettingGroup extends StatelessWidget {
// delete account button
// only show the delete account button in cloud mode
- if (userProfile.workspaceAuthType == AuthTypePB.Server) ...[
+ if (userProfile.userAuthType == AuthTypePB.Server) ...[
VSpace(theme.spacing.l),
AFOutlinedTextButton.destructive(
alignment: Alignment.center,
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 144c058ccc..9b1ccdfe4b 100644
--- a/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart
+++ b/frontend/appflowy_flutter/lib/startup/tasks/appflowy_cloud_task.dart
@@ -111,7 +111,7 @@ class AppFlowyCloudDeepLink {
(_) async {
final deviceId = await getDeviceId();
final payload = OauthSignInPB(
- authenticator: AuthTypePB.Server,
+ authType: AuthTypePB.Server,
map: {
AuthServiceMapKeys.signInURL: uri.toString(),
AuthServiceMapKeys.deviceId: deviceId,
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 8be71dc648..153e8dc191 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
@@ -58,7 +58,7 @@ class AppFlowyCloudMockAuthService implements AuthService {
return getSignInURLResult.fold(
(urlPB) async {
final payload = OauthSignInPB(
- authenticator: AuthTypePB.Server,
+ authType: AuthTypePB.Server,
map: {
AuthServiceMapKeys.signInURL: urlPB.signInUrl,
AuthServiceMapKeys.deviceId: deviceId,
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 80dd5ca3c9..a10d0f5d7d 100644
--- a/frontend/appflowy_flutter/lib/user/application/password/password_bloc.dart
+++ b/frontend/appflowy_flutter/lib/user/application/password/password_bloc.dart
@@ -46,7 +46,7 @@ class PasswordBloc extends Bloc<PasswordEvent, PasswordState> {
bool _isInitialized = false;
Future<void> _init() async {
- if (userProfile.workspaceAuthType == AuthTypePB.Local) {
+ if (userProfile.userAuthType == 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 ddb1a07f96..f06f5c361c 100644
--- a/frontend/appflowy_flutter/lib/user/presentation/anon_user.dart
+++ b/frontend/appflowy_flutter/lib/user/presentation/anon_user.dart
@@ -74,8 +74,8 @@ class AnonUserItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final icon = isSelected ? const FlowySvg(FlowySvgs.check_s) : null;
- final isDisabled = isSelected || user.workspaceAuthType != AuthTypePB.Local;
- final desc = "${user.name}\t ${user.workspaceAuthType}\t";
+ final isDisabled = isSelected || user.userAuthType != AuthTypePB.Local;
+ final desc = "${user.name}\t ${user.userAuthType}\t";
final child = SizedBox(
height: 30,
child: FlowyButton(
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 d7afb03e87..3e19703c04 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
@@ -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.workspaceAuthType != AuthTypePB.Local) ...[
+ state.userProfile.userAuthType != AuthTypePB.Local) ...[
SettingsCategory(
title: LocaleKeys.newSettings_myAccount_myAccount.tr(),
children: [
@@ -82,30 +82,30 @@ class _SettingsAccountViewState extends State<SettingsAccountView> {
),
AccountSignInOutSection(
userProfile: state.userProfile,
- onAction: state.userProfile.workspaceAuthType ==
- AuthTypePB.Local
- ? widget.didLogin
- : widget.didLogout,
- signIn: state.userProfile.workspaceAuthType ==
- AuthTypePB.Local,
+ onAction:
+ state.userProfile.userAuthType == AuthTypePB.Local
+ ? widget.didLogin
+ : widget.didLogout,
+ signIn:
+ state.userProfile.userAuthType == AuthTypePB.Local,
),
],
),
],
if (isAuthEnabled &&
- state.userProfile.workspaceAuthType == AuthTypePB.Local) ...[
+ state.userProfile.userAuthType == AuthTypePB.Local) ...[
SettingsCategory(
title: LocaleKeys.settings_accountPage_login_title.tr(),
children: [
AccountSignInOutSection(
userProfile: state.userProfile,
- onAction: state.userProfile.workspaceAuthType ==
- AuthTypePB.Local
- ? widget.didLogin
- : widget.didLogout,
- signIn: state.userProfile.workspaceAuthType ==
- AuthTypePB.Local,
+ onAction:
+ state.userProfile.userAuthType == AuthTypePB.Local
+ ? widget.didLogin
+ : widget.didLogout,
+ signIn:
+ state.userProfile.userAuthType == AuthTypePB.Local,
),
],
),
@@ -120,7 +120,7 @@ class _SettingsAccountViewState extends State<SettingsAccountView> {
),
// user deletion
- if (widget.userProfile.workspaceAuthType == AuthTypePB.Server)
+ if (widget.userProfile.userAuthType == AuthTypePB.Server)
const AccountDeletionButton(),
],
);
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 11a653b723..8f7ca7b945 100644
--- a/frontend/rust-lib/event-integration-test/src/user_event.rs
+++ b/frontend/rust-lib/event-integration-test/src/user_event.rs
@@ -155,7 +155,7 @@ impl EventIntegrationTest {
map.insert(USER_DEVICE_ID.to_string(), Uuid::new_v4().to_string());
let payload = OauthSignInPB {
map,
- authenticator: AuthTypePB::Server,
+ auth_type: AuthTypePB::Server,
};
let user_profile = EventBuilder::new(self.clone())
diff --git a/frontend/rust-lib/flowy-user/src/entities/auth.rs b/frontend/rust-lib/flowy-user/src/entities/auth.rs
index a61ba5cc96..2e17fd5a03 100644
--- a/frontend/rust-lib/flowy-user/src/entities/auth.rs
+++ b/frontend/rust-lib/flowy-user/src/entities/auth.rs
@@ -144,7 +144,7 @@ pub struct OauthSignInPB {
pub map: HashMap<String, String>,
#[pb(index = 2)]
- pub authenticator: AuthTypePB,
+ pub auth_type: AuthTypePB,
}
#[derive(ProtoBuf, Default)]
diff --git a/frontend/rust-lib/flowy-user/src/event_handler.rs b/frontend/rust-lib/flowy-user/src/event_handler.rs
index 54f62a84cd..ee8f1832cd 100644
--- a/frontend/rust-lib/flowy-user/src/event_handler.rs
+++ b/frontend/rust-lib/flowy-user/src/event_handler.rs
@@ -334,7 +334,7 @@ pub async fn oauth_sign_in_handler(
) -> DataResult<UserProfilePB, FlowyError> {
let manager = upgrade_manager(manager)?;
let params = data.into_inner();
- let authenticator: AuthType = params.authenticator.into();
+ let authenticator: AuthType = params.auth_type.into();
let user_profile = manager
.sign_up(authenticator, BoxAny::new(params.map))
.await?;
diff --git a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
index df4850039b..40cf6c1094 100644
--- a/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
+++ b/frontend/rust-lib/flowy-user/src/user_manager/manager.rs
@@ -425,10 +425,10 @@ impl UserManager {
) -> FlowyResult<()> {
let new_session = Session::from(&response);
let workspace_id = Uuid::parse_str(&new_session.workspace_id)?;
- self.prepare_user(&new_session).await;
self
.save_auth_data(&response, *auth_type, &new_session)
.await?;
+ self.prepare_user(&new_session).await;
let _ = self
.initial_user_awareness(
new_session.user_id,