chore: use auth type instead of workspace auth type

This commit is contained in:
Nathan 2025-04-24 13:38:25 +08:00
parent 6a887fdca9
commit 718c5ad16f
10 changed files with 25 additions and 25 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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;
}

View file

@ -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(

View file

@ -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(),
],
);

View file

@ -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())

View file

@ -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)]

View file

@ -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?;

View file

@ -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,