mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
feat: workspace service in user crate (#4373)
* refactor: user manager * feat: implement workspace service * refactor: migrate user data when sign up * chore: fmt * chore: enable beta cloud * chore: update ci * chore: trim slash
This commit is contained in:
38
frontend/appflowy_flutter/lib/env/cloud_env.dart
vendored
38
frontend/appflowy_flutter/lib/env/cloud_env.dart
vendored
@ -28,6 +28,9 @@ Future<void> setAuthenticatorType(AuthenticatorType ty) async {
|
||||
case AuthenticatorType.appflowyCloud:
|
||||
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 2.toString());
|
||||
break;
|
||||
case AuthenticatorType.appflowyCloudSelfHost:
|
||||
getIt<KeyValueStorage>().set(KVKeys.kCloudType, 3.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +55,8 @@ Future<AuthenticatorType> getAuthenticatorType() async {
|
||||
return AuthenticatorType.supabase;
|
||||
case "2":
|
||||
return AuthenticatorType.appflowyCloud;
|
||||
case "3":
|
||||
return AuthenticatorType.appflowyCloudSelfHost;
|
||||
default:
|
||||
return AuthenticatorType.local;
|
||||
}
|
||||
@ -75,7 +80,8 @@ bool get isAuthEnabled {
|
||||
return env.supabaseConfig.isValid;
|
||||
}
|
||||
|
||||
if (env.authenticatorType == AuthenticatorType.appflowyCloud) {
|
||||
if (env.authenticatorType == AuthenticatorType.appflowyCloudSelfHost ||
|
||||
env.authenticatorType == AuthenticatorType.appflowyCloud) {
|
||||
return env.appflowyCloudConfig.isValid;
|
||||
}
|
||||
|
||||
@ -92,20 +98,28 @@ bool get isAuthEnabled {
|
||||
/// if the application is in release or develop mode and the current cloud type
|
||||
/// is `CloudType.supabase`. Otherwise, it returns `false`.
|
||||
bool get isSupabaseEnabled {
|
||||
return currentCloudType() == AuthenticatorType.supabase;
|
||||
return currentCloudType().isSupabaseEnabled;
|
||||
}
|
||||
|
||||
/// Determines if AppFlowy Cloud is enabled.
|
||||
bool get isAppFlowyCloudEnabled {
|
||||
return currentCloudType() == AuthenticatorType.appflowyCloud;
|
||||
return currentCloudType().isAppFlowyCloudEnabled;
|
||||
}
|
||||
|
||||
enum AuthenticatorType {
|
||||
local,
|
||||
supabase,
|
||||
appflowyCloud;
|
||||
appflowyCloud,
|
||||
appflowyCloudSelfHost;
|
||||
|
||||
bool get isLocal => this == AuthenticatorType.local;
|
||||
|
||||
bool get isAppFlowyCloudEnabled =>
|
||||
this == AuthenticatorType.appflowyCloudSelfHost ||
|
||||
this == AuthenticatorType.appflowyCloud;
|
||||
|
||||
bool get isSupabaseEnabled => this == AuthenticatorType.supabase;
|
||||
|
||||
int get value {
|
||||
switch (this) {
|
||||
case AuthenticatorType.local:
|
||||
@ -114,6 +128,8 @@ enum AuthenticatorType {
|
||||
return 1;
|
||||
case AuthenticatorType.appflowyCloud:
|
||||
return 2;
|
||||
case AuthenticatorType.appflowyCloudSelfHost:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,6 +141,8 @@ enum AuthenticatorType {
|
||||
return AuthenticatorType.supabase;
|
||||
case 2:
|
||||
return AuthenticatorType.appflowyCloud;
|
||||
case 3:
|
||||
return AuthenticatorType.appflowyCloudSelfHost;
|
||||
default:
|
||||
return AuthenticatorType.local;
|
||||
}
|
||||
@ -160,7 +178,17 @@ class AppFlowyCloudSharedEnv {
|
||||
// If [Env.enableCustomCloud] is true, then use the custom cloud configuration.
|
||||
if (Env.enableCustomCloud) {
|
||||
// Use the custom cloud configuration.
|
||||
final cloudType = await getAuthenticatorType();
|
||||
var cloudType = await getAuthenticatorType();
|
||||
|
||||
// In the backend, the value '2' represents the use of AppFlowy Cloud. However, in the frontend,
|
||||
// we distinguish between [AuthenticatorType.appflowyCloudSelfHost] and [AuthenticatorType.appflowyCloud].
|
||||
// When the cloud type is [AuthenticatorType.appflowyCloudSelfHost] in the frontend, it should be
|
||||
// converted to [AuthenticatorType.appflowyCloud] to align with the backend representation,
|
||||
// where both types are indicated by the value '2'.
|
||||
if (cloudType == AuthenticatorType.appflowyCloudSelfHost) {
|
||||
cloudType = AuthenticatorType.appflowyCloud;
|
||||
}
|
||||
|
||||
final appflowyCloudConfig = cloudType.isLocal
|
||||
? AppFlowyCloudConfiguration.defaultConfig()
|
||||
: await getAppFlowyCloudConfig();
|
||||
|
6
frontend/appflowy_flutter/lib/env/env.dart
vendored
6
frontend/appflowy_flutter/lib/env/env.dart
vendored
@ -8,8 +8,10 @@ part 'env.g.dart';
|
||||
abstract class Env {
|
||||
// This flag is used to decide if users can dynamically configure cloud settings. It turns true when a .env file exists containing the APPFLOWY_CLOUD_URL variable. By default, this is set to false.
|
||||
static bool get enableCustomCloud {
|
||||
return Env.authenticatorType == AuthenticatorType.appflowyCloud.value &&
|
||||
_Env.afCloudUrl.isEmpty;
|
||||
return Env.authenticatorType ==
|
||||
AuthenticatorType.appflowyCloudSelfHost.value ||
|
||||
Env.authenticatorType == AuthenticatorType.appflowyCloud.value &&
|
||||
_Env.afCloudUrl.isEmpty;
|
||||
}
|
||||
|
||||
@EnviedField(
|
||||
|
Reference in New Issue
Block a user