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.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
feat: support 'forgot password', 'setup password' and 'change password' on mobile (#7841)
Lucasae5f06ad1a44
diff --git a/frontend/appflowy_flutter/ios/Podfile.lock b/frontend/appflowy_flutter/ios/Podfile.lockindex 07f8217a78..24510f46e7 100644--- a/frontend/appflowy_flutter/ios/Podfile.lock+++ b/frontend/appflowy_flutter/ios/Podfile.lock@@ -8,35 +8,35 @@ PODS:- ReachabilitySwift- device_info_plus (0.0.1):- Flutter- - DKImagePickerController/Core (4.3.4):+ - DKImagePickerController/Core (4.3.9):- DKImagePickerController/ImageDataManager- DKImagePickerController/Resource- - DKImagePickerController/ImageDataManager (4.3.4)- - DKImagePickerController/PhotoGallery (4.3.4):+ - DKImagePickerController/ImageDataManager (4.3.9)+ - DKImagePickerController/PhotoGallery (4.3.9):- DKImagePickerController/Core- DKPhotoGallery- - DKImagePickerController/Resource (4.3.4)- - DKPhotoGallery (0.0.17):- - DKPhotoGallery/Core (= 0.0.17)- - DKPhotoGallery/Model (= 0.0.17)- - DKPhotoGallery/Preview (= 0.0.17)- - DKPhotoGallery/Resource (= 0.0.17)+ - DKImagePickerController/Resource (4.3.9)+ - DKPhotoGallery (0.0.19):+ - DKPhotoGallery/Core (= 0.0.19)+ - DKPhotoGallery/Model (= 0.0.19)+ - DKPhotoGallery/Preview (= 0.0.19)+ - DKPhotoGallery/Resource (= 0.0.19)- SDWebImage- SwiftyGif- - DKPhotoGallery/Core (0.0.17):+ - DKPhotoGallery/Core (0.0.19):- DKPhotoGallery/Model- DKPhotoGallery/Preview- SDWebImage- SwiftyGif- - DKPhotoGallery/Model (0.0.17):+ - DKPhotoGallery/Model (0.0.19):- SDWebImage- SwiftyGif- - DKPhotoGallery/Preview (0.0.17):+ - DKPhotoGallery/Preview (0.0.19):- DKPhotoGallery/Model- DKPhotoGallery/Resource- SDWebImage- SwiftyGif- - DKPhotoGallery/Resource (0.0.17):+ - DKPhotoGallery/Resource (0.0.19):- SDWebImage- SwiftyGif- file_picker (0.0.1):@@ -65,17 +65,17 @@ PODS:- FlutterMacOS- permission_handler_apple (9.3.0):- Flutter- - ReachabilitySwift (5.0.0)+ - ReachabilitySwift (5.2.4)- saver_gallery (0.0.1):- Flutter- - SDWebImage (5.14.2):- - SDWebImage/Core (= 5.14.2)- - SDWebImage/Core (5.14.2)- - Sentry/HybridSDK (8.35.1)- - sentry_flutter (8.8.0):+ - SDWebImage (5.21.0):+ - SDWebImage/Core (= 5.21.0)+ - SDWebImage/Core (5.21.0)+ - Sentry/HybridSDK (8.46.0)+ - sentry_flutter (8.14.2):- Flutter- FlutterMacOS- - Sentry/HybridSDK (= 8.35.1)+ - Sentry/HybridSDK (= 8.46.0)- share_plus (0.0.1):- Flutter- shared_preferences_foundation (0.0.1):@@ -86,8 +86,8 @@ PODS:- FlutterMacOS- super_native_extensions (0.0.1):- Flutter- - SwiftyGif (5.4.3)- - Toast (4.0.0)+ - SwiftyGif (5.4.5)+ - Toast (4.1.1)- url_launcher_ios (0.0.1):- Flutter- webview_flutter_wkwebview (0.0.1):@@ -185,8 +185,8 @@ SPEC CHECKSUMS:appflowy_backend: 78f6a053f756e6bc29bcc5a2106cbe77b756e97aconnectivity_plus: 481668c94744c30c53b8895afb39159d1e619bdfdevice_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe- DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac- DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179+ DKImagePickerController: 946cec48c7873164274ecc4624d19e3da4c1ef3c+ DKPhotoGallery: b3834fecb755ee09a593d7c9e389d8b5d6deed60file_picker: 9b3292d7c8bc68c8a7bf8eb78f730e49c8efc517flowy_infra_ui: 931b73a18b54a392ab6152eebe29a63a30751f53Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7@@ -199,17 +199,17 @@ SPEC CHECKSUMS:package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d- ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825+ ReachabilitySwift: 32793e867593cfc1177f5d16491e3a197d2fccdasaver_gallery: af2d0c762dafda254e0ad025ef0dabd6506cd490- SDWebImage: b9a731e1d6307f44ca703b3976d18c24ca561e84- Sentry: 1fe34e9c2cbba1e347623610d26db121dcb569f1- sentry_flutter: e24b397f9a61fa5bbefd8279c3b2242ca86faa90+ SDWebImage: f84b0feeb08d2d11e6a9b843cb06d75ebf5b8868+ Sentry: da60d980b197a46db0b35ea12cb8f39af48d8854+ sentry_flutter: 27892878729f42701297c628eb90e7c6529f3684share_plus: 50da8cb520a8f0f65671c6c6a99b3617ed10a58ashared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0super_native_extensions: b763c02dc3a8fd078389f410bf15149179020cb4- SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780- Toast: 91b396c56ee72a5790816f40d3a94dd357abc196+ SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4+ Toast: 1f5ea13423a1e6674c4abdac5be53587ae481c4eurl_launcher_ios: 694010445543906933d732453a59da0a173ae33dwebview_flutter_wkwebview: 44d4dee7d7056d5ad185d25b38404436d56c547cdiff --git a/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/show_mobile_bottom_sheet.dart b/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/show_mobile_bottom_sheet.dartindex a0fa5dc6aa..5f7b0096d3 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/show_mobile_bottom_sheet.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/bottom_sheet/show_mobile_bottom_sheet.dart@@ -1,5 +1,6 @@import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_buttons.dart';import 'package:appflowy/plugins/base/drag_handler.dart';+import 'package:appflowy_ui/appflowy_ui.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -235,6 +236,7 @@ class BottomSheetHeader extends StatelessWidget {@overrideWidget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context);return Padding(padding: const EdgeInsets.only(bottom: 4.0),child: SizedBox(@@ -265,11 +267,11 @@ class BottomSheetHeader extends StatelessWidget {Align(child: Container(constraints: const BoxConstraints(maxWidth: 250),- child: FlowyText(+ child: Text(title,- fontSize: 17.0,- fontWeight: FontWeight.w500,- overflow: TextOverflow.ellipsis,+ style: theme.textStyle.heading4.prominent(+ color: theme.textColorScheme.primary,+ ),),),),diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_setting_page.dart b/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_setting_page.dartindex a01df20549..0b160c9a8e 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_setting_page.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/home/mobile_home_setting_page.dart@@ -85,7 +85,8 @@ class _MobileHomeSettingPageState extends State<MobileHomeSettingPage> {PersonalInfoSettingGroup(userProfile: userProfile,),- const WorkspaceSettingGroup(),+ if (state.userProfile.userAuthType == AuthTypePB.Server)+ const WorkspaceSettingGroup(),const AppearanceSettingGroup(),const LanguageSettingGroup(),if (Env.enableCustomCloud) const CloudSettingGroup(),diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/personal_info/edit_username_bottom_sheet.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/personal_info/edit_username_bottom_sheet.dartindex 04fe9e9cf7..f7e51e9f88 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/personal_info/edit_username_bottom_sheet.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/personal_info/edit_username_bottom_sheet.dart@@ -1,4 +1,5 @@import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flutter/material.dart';@@ -64,12 +65,11 @@ class _EditUsernameBottomSheetState extends State<EditUsernameBottomSheet> {),),const VSpace(16),- SizedBox(- width: double.infinity,- child: ElevatedButton(- onPressed: submitUserName,- child: Text(LocaleKeys.button_update.tr()),- ),+ AFFilledTextButton.primary(+ text: LocaleKeys.button_update.tr(),+ onTap: submitUserName,+ size: AFButtonSize.l,+ alignment: Alignment.center,),],);diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/personal_info/personal_info_setting_group.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/personal_info/personal_info_setting_group.dartindex f074ec685d..6b1e6d0973 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/personal_info/personal_info_setting_group.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/personal_info/personal_info_setting_group.dart@@ -2,10 +2,15 @@ import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet.dart';import 'package:appflowy/mobile/presentation/setting/widgets/mobile_setting_trailing.dart';import 'package:appflowy/startup/startup.dart';+import 'package:appflowy/user/application/auth/auth_service.dart';+import 'package:appflowy/user/application/password/password_bloc.dart';import 'package:appflowy/workspace/application/user/prelude.dart';+import 'package:appflowy/workspace/presentation/settings/pages/account/password/change_password.dart';+import 'package:appflowy/workspace/presentation/settings/pages/account/password/setup_password.dart';import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/widget/spacing.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';@@ -22,11 +27,19 @@ class PersonalInfoSettingGroup extends StatelessWidget {@overrideWidget build(BuildContext context) {- final theme = AppFlowyTheme.of(context);- return BlocProvider<SettingsUserViewBloc>(- create: (context) => getIt<SettingsUserViewBloc>(- param1: userProfile,- )..add(const SettingsUserEvent.initial()),+ return MultiBlocProvider(+ providers: [+ BlocProvider<SettingsUserViewBloc>(+ create: (context) => getIt<SettingsUserViewBloc>(+ param1: userProfile,+ )..add(const SettingsUserEvent.initial()),+ ),+ BlocProvider(+ create: (context) => PasswordBloc(userProfile)+ ..add(PasswordEvent.init())+ ..add(PasswordEvent.checkHasPassword()),+ ),+ ],child: BlocSelector<SettingsUserViewBloc, SettingsUserState, String>(selector: (state) => state.userProfile.name,builder: (context, userName) {@@ -59,19 +72,111 @@ class PersonalInfoSettingGroup extends StatelessWidget {);},),- MobileSettingItem(- name: 'Email',- trailing: Text(- userProfile.email,- style: theme.textStyle.heading4.standard(- color: theme.textColorScheme.secondary,- ),- ),- ),+ ...userProfile.userAuthType == AuthTypePB.Server+ ? [+ _buildEmailItem(context, userProfile),+ _buildPasswordItem(context, userProfile),+ ]+ : [+ _buildLoginItem(context, userProfile),+ ],],);},),);}++ Widget _buildEmailItem(BuildContext context, UserProfilePB userProfile) {+ final theme = AppFlowyTheme.of(context);+ return MobileSettingItem(+ name: LocaleKeys.settings_accountPage_email_title.tr(),+ trailing: Text(+ userProfile.email,+ style: theme.textStyle.heading4.standard(+ color: theme.textColorScheme.secondary,+ ),+ ),+ );+ }++ Widget _buildPasswordItem(BuildContext context, UserProfilePB userProfile) {+ return BlocBuilder<PasswordBloc, PasswordState>(+ builder: (context, state) {+ final hasPassword = state.hasPassword;+ final title = hasPassword+ ? LocaleKeys.newSettings_myAccount_password_changePassword.tr()+ : LocaleKeys.newSettings_myAccount_password_setupPassword.tr();+ final passwordBloc = context.read<PasswordBloc>();+ return MobileSettingItem(+ name: LocaleKeys.newSettings_myAccount_password_title.tr(),+ trailing: MobileSettingTrailing(+ text: '',+ ),+ onTap: () {+ showMobileBottomSheet(+ context,+ showHeader: true,+ title: title,+ showCloseButton: true,+ showDragHandle: true,+ showDivider: false,+ padding: const EdgeInsets.symmetric(horizontal: 16),+ builder: (_) {+ Widget child;+ if (hasPassword) {+ child = ChangePasswordDialogContent(+ userProfile: userProfile,+ showTitle: false,+ showCloseAndSaveButton: false,+ showSaveButton: true,+ padding: EdgeInsets.zero,+ );+ } else {+ child = SetupPasswordDialogContent(+ userProfile: userProfile,+ showTitle: false,+ showCloseAndSaveButton: false,+ showSaveButton: true,+ padding: EdgeInsets.zero,+ );+ }+ return BlocProvider.value(+ value: passwordBloc,+ child: child,+ );+ },+ );+ },+ );+ },+ );+ }++ Widget _buildLoginItem(BuildContext context, UserProfilePB userProfile) {+ final theme = AppFlowyTheme.of(context);+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ LocaleKeys.signIn_youAreInLocalMode.tr(),+ style: theme.textStyle.body.standard(+ color: theme.textColorScheme.secondary,+ ),+ ),+ VSpace(theme.spacing.m),+ AFOutlinedTextButton.normal(+ text: LocaleKeys.signIn_loginToAppFlowyCloud.tr(),+ size: AFButtonSize.l,+ alignment: Alignment.center,+ onTap: () async {+ // logout and restart the app+ await getIt<AuthService>().signOut();+ await runAppFlowy();+ },+ ),+ VSpace(theme.spacing.m),+ ],+ );+ }}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.dartindex 081a7672ae..ebae126783 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@@ -32,7 +32,7 @@ class UserSessionSettingGroup extends StatelessWidget {children: [// third party sign in buttonsif (showThirdPartyLogin) _buildThirdPartySignInButtons(context),- const VSpace(8.0),+ VSpace(theme.spacing.xxl),// logout buttonMobileLogoutButton(@@ -43,7 +43,7 @@ class UserSessionSettingGroup extends StatelessWidget {// delete account button// only show the delete account button in cloud modeif (userProfile.userAuthType == AuthTypePB.Server) ...[- VSpace(theme.spacing.l),+ VSpace(theme.spacing.xxl),AFOutlinedTextButton.destructive(alignment: Alignment.center,text: LocaleKeys.button_deleteAccount.tr(),@@ -54,6 +54,8 @@ class UserSessionSettingGroup extends StatelessWidget {size: AFButtonSize.l,),],++ VSpace(theme.spacing.xxl),],);}diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/add_members_screen.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/add_members_screen.dartindex e760e91779..729993271f 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/add_members_screen.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/add_members_screen.dart@@ -83,7 +83,8 @@ class _InviteMemberPageState extends State<_InviteMemberPage> {return BlocProvider<WorkspaceMemberBloc>(create: (context) => WorkspaceMemberBloc(userProfile: userProfile)- ..add(const WorkspaceMemberEvent.initial()),+ ..add(const WorkspaceMemberEvent.initial())+ ..add(const WorkspaceMemberEvent.getInviteCode()),child: BlocConsumer<WorkspaceMemberBloc, WorkspaceMemberState>(listener: _onListener,builder: (context, state) {diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_member_by_link.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_member_by_link.dartindex fad7fe3e39..a832735ef0 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_member_by_link.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_member_by_link.dart@@ -83,7 +83,8 @@ class _InviteMemberPageState extends State<_InviteMemberPage> {return BlocProvider<WorkspaceMemberBloc>(create: (context) => WorkspaceMemberBloc(userProfile: userProfile)- ..add(const WorkspaceMemberEvent.initial()),+ ..add(const WorkspaceMemberEvent.initial())+ ..add(const WorkspaceMemberEvent.getInviteCode()),child: BlocConsumer<WorkspaceMemberBloc, WorkspaceMemberState>(listener: _onListener,builder: (context, state) {diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_members_screen.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_members_screen.dartindex 40cd7ffe4f..77d21697d3 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_members_screen.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/invite_members_screen.dart@@ -103,7 +103,8 @@ class _InviteMemberPageState extends State<_InviteMemberPage> {return BlocProvider<WorkspaceMemberBloc>(create: (context) => WorkspaceMemberBloc(userProfile: userProfile)- ..add(const WorkspaceMemberEvent.initial()),+ ..add(const WorkspaceMemberEvent.initial())+ ..add(const WorkspaceMemberEvent.getInviteCode()),child: BlocConsumer<WorkspaceMemberBloc, WorkspaceMemberState>(listener: _onListener,builder: (context, state) {diff --git a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/workspace_setting_group.dart b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/workspace_setting_group.dartindex f7036d33d4..fd981a4f2b 100644--- a/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/workspace_setting_group.dart+++ b/frontend/appflowy_flutter/lib/mobile/presentation/setting/workspace/workspace_setting_group.dart@@ -3,8 +3,8 @@ import 'package:appflowy/mobile/presentation/setting/widgets/mobile_setting_traiimport 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flutter/material.dart';+import 'package:flutter_bloc/flutter_bloc.dart';import 'package:go_router/go_router.dart';-import 'package:provider/provider.dart';import '../widgets/widgets.dart';import 'invite_members_screen.dart';@@ -16,26 +16,24 @@ class WorkspaceSettingGroup extends StatelessWidget {@overrideWidget build(BuildContext context) {- final memberCount = context- .read<UserWorkspaceBloc>()- .state- .currentWorkspace- ?.memberCount- .toString() ??- '';- return MobileSettingGroup(- groupTitle: LocaleKeys.settings_appearance_members_label.tr(),- settingItemList: [- MobileSettingItem(- name: LocaleKeys.settings_appearance_members_label.tr(),- trailing: MobileSettingTrailing(- text: memberCount,- ),- onTap: () {- context.push(InviteMembersScreen.routeName);- },- ),- ],+ return BlocBuilder<UserWorkspaceBloc, UserWorkspaceState>(+ builder: (context, state) {+ final currentWorkspace = state.currentWorkspace;+ return MobileSettingGroup(+ groupTitle: LocaleKeys.settings_appearance_members_label.tr(),+ settingItemList: [+ MobileSettingItem(+ name: LocaleKeys.settings_appearance_members_label.tr(),+ trailing: MobileSettingTrailing(+ text: currentWorkspace?.memberCount.toString() ?? '',+ ),+ onTap: () {+ context.push(InviteMembersScreen.routeName);+ },+ ),+ ],+ );+ },);}}diff --git a/frontend/appflowy_flutter/lib/user/application/password/password_http_service.dart b/frontend/appflowy_flutter/lib/user/application/password/password_http_service.dartindex c56c4f595d..5a386b4515 100644--- a/frontend/appflowy_flutter/lib/user/application/password/password_http_service.dart+++ b/frontend/appflowy_flutter/lib/user/application/password/password_http_service.dart@@ -9,18 +9,21 @@ enum PasswordEndpoint {changePassword,forgotPassword,setupPassword,- checkHasPassword;+ checkHasPassword,+ verifyResetPasswordToken;String get path {switch (this) {case PasswordEndpoint.changePassword:return '/gotrue/user/change-password';case PasswordEndpoint.forgotPassword:- return '/gotrue/user/recover';+ return '/gotrue/recover';case PasswordEndpoint.setupPassword:return '/gotrue/user/change-password';case PasswordEndpoint.checkHasPassword:return '/gotrue/user/auth-info';+ case PasswordEndpoint.verifyResetPasswordToken:+ return '/gotrue/verify';}}@@ -29,6 +32,7 @@ enum PasswordEndpoint {case PasswordEndpoint.changePassword:case PasswordEndpoint.setupPassword:case PasswordEndpoint.forgotPassword:+ case PasswordEndpoint.verifyResetPasswordToken:return 'POST';case PasswordEndpoint.checkHasPassword:return 'GET';@@ -45,7 +49,8 @@ class PasswordHttpService {});final String baseUrl;- final String authToken;++ String authToken;final http.Client client = http.Client();@@ -132,6 +137,36 @@ class PasswordHttpService {}}+ // Verify the reset password token+ Future<FlowyResult<String, FlowyError>> verifyResetPasswordToken({+ required String email,+ required String token,+ }) async {+ final result = await _makeRequest(+ endpoint: PasswordEndpoint.verifyResetPasswordToken,+ body: {+ 'type': 'recovery',+ 'email': email,+ 'token': token,+ },+ errorMessage: 'Failed to verify reset password token',+ );++ try {+ return result.fold(+ (data) {+ final authToken = data['access_token'];+ return FlowyResult.success(authToken);+ },+ (error) => FlowyResult.failure(error),+ );+ } catch (e) {+ return FlowyResult.failure(+ FlowyError(msg: 'Failed to verify reset password token: $e'),+ );+ }+ }+/// Makes a request to the specified endpoint with the given bodyFuture<FlowyResult<dynamic, FlowyError>> _makeRequest({required PasswordEndpoint endpoint,diff --git a/frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dart b/frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dartindex 2e28db48ad..6e6b361981 100644--- a/frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dart+++ b/frontend/appflowy_flutter/lib/user/application/sign_in_bloc.dart@@ -4,6 +4,7 @@ import 'package:appflowy/startup/startup.dart';import 'package:appflowy/startup/tasks/appflowy_cloud_task.dart';import 'package:appflowy/startup/tasks/deeplink/deeplink_handler.dart';import 'package:appflowy/user/application/auth/auth_service.dart';+import 'package:appflowy/user/application/password/password_http_service.dart';import 'package:appflowy_backend/log.dart';import 'package:appflowy_backend/protobuf/flowy-error/code.pb.dart';import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';@@ -26,6 +27,14 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {add(SignInEvent.deepLinkStateChange(value));});++ getAppFlowyCloudUrl().then((baseUrl) {+ passwordService = PasswordHttpService(+ baseUrl: baseUrl,+ authToken:+ '', // the user is not signed in yet, the auth token should be empty+ );+ });}on<SignInEvent>(@@ -83,12 +92,25 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {switchLoginType: (type) {emit(state.copyWith(loginType: type));},+ forgotPassword: (email) => _onForgotPassword(emit, email: email),+ validateResetPasswordToken: (email, token) async =>+ _onValidateResetPasswordToken(+ emit,+ email: email,+ token: token,+ ),+ resetPassword: (email, newPassword) async => _onResetPassword(+ emit,+ email: email,+ newPassword: newPassword,+ ),);},);}final AuthService authService;+ PasswordHttpService? passwordService;VoidCallback? deepLinkStateListener;@override@@ -290,6 +312,142 @@ class SignInBloc extends Bloc<SignInEvent, SignInState> {);}+ Future<void> _onForgotPassword(+ Emitter<SignInState> emit, {+ required String email,+ }) async {+ if (state.isSubmitting) {+ Log.error('Forgot password is already in progress');+ return;+ }++ emit(+ state.copyWith(+ isSubmitting: true,+ forgotPasswordSuccessOrFail: null,+ validateResetPasswordTokenSuccessOrFail: null,+ resetPasswordSuccessOrFail: null,+ ),+ );++ final result = await passwordService?.forgotPassword(email: email);++ result?.fold(+ (success) {+ emit(+ state.copyWith(+ isSubmitting: false,+ forgotPasswordSuccessOrFail: FlowyResult.success(true),+ ),+ );+ },+ (error) {+ emit(+ state.copyWith(+ isSubmitting: false,+ forgotPasswordSuccessOrFail: FlowyResult.failure(error),+ ),+ );+ },+ );+ }++ Future<void> _onValidateResetPasswordToken(+ Emitter<SignInState> emit, {+ required String email,+ required String token,+ }) async {+ if (state.isSubmitting) {+ Log.error('Validate reset password token is already in progress');+ return;+ }++ Log.info('Validate reset password token: $email, $token');++ emit(+ state.copyWith(+ isSubmitting: true,+ validateResetPasswordTokenSuccessOrFail: null,+ resetPasswordSuccessOrFail: null,+ ),+ );++ final result = await passwordService?.verifyResetPasswordToken(+ email: email,+ token: token,+ );++ result?.fold(+ (authToken) {+ Log.info('Validate reset password token success: $authToken');++ passwordService?.authToken = authToken;++ emit(+ state.copyWith(+ isSubmitting: false,+ validateResetPasswordTokenSuccessOrFail: FlowyResult.success(true),+ ),+ );+ },+ (error) {+ Log.error('Validate reset password token failed: $error');++ emit(+ state.copyWith(+ isSubmitting: false,+ validateResetPasswordTokenSuccessOrFail: FlowyResult.failure(error),+ ),+ );+ },+ );+ }++ Future<void> _onResetPassword(+ Emitter<SignInState> emit, {+ required String email,+ required String newPassword,+ }) async {+ if (state.isSubmitting) {+ Log.error('Reset password is already in progress');+ return;+ }++ Log.info('Reset password: $email, ${newPassword.hashCode}');++ emit(+ state.copyWith(+ isSubmitting: true,+ resetPasswordSuccessOrFail: null,+ ),+ );++ final result = await passwordService?.setupPassword(+ newPassword: newPassword,+ );++ result?.fold(+ (success) {+ Log.info('Reset password success');+ emit(+ state.copyWith(+ isSubmitting: false,+ resetPasswordSuccessOrFail: FlowyResult.success(true),+ ),+ );+ },+ (error) {+ Log.error('Reset password failed: $error');+ emit(+ state.copyWith(+ isSubmitting: false,+ resetPasswordSuccessOrFail: FlowyResult.failure(error),+ ),+ );+ },+ );+ }+SignInState _stateFromCode(FlowyError error) {Log.error('SignInState _stateFromCode: ${error.msg}');@@ -365,6 +523,21 @@ class SignInEvent with _$SignInEvent {const factory SignInEvent.cancel() = Cancel;const factory SignInEvent.switchLoginType(LoginType type) = SwitchLoginType;++ // password+ const factory SignInEvent.forgotPassword({+ required String email,+ }) = ForgotPassword;++ const factory SignInEvent.validateResetPasswordToken({+ required String email,+ required String token,+ }) = ValidateResetPasswordToken;++ const factory SignInEvent.resetPassword({+ required String email,+ required String newPassword,+ }) = ResetPassword;}// we support sign in directly without sign up, but we want to allow the users to sign up if they want to@@ -383,6 +556,10 @@ class SignInState with _$SignInState {required String? passwordError,required String? emailError,required FlowyResult<UserProfilePB, FlowyError>? successOrFail,+ required FlowyResult<bool, FlowyError>? forgotPasswordSuccessOrFail,+ required FlowyResult<bool, FlowyError>?+ validateResetPasswordTokenSuccessOrFail,+ required FlowyResult<bool, FlowyError>? resetPasswordSuccessOrFail,@Default(LoginType.signIn) LoginType loginType,}) = _SignInState;@@ -391,5 +568,8 @@ class SignInState with _$SignInState {passwordError: null,emailError: null,successOrFail: null,+ forgotPasswordSuccessOrFail: null,+ validateResetPasswordTokenSuccessOrFail: null,+ resetPasswordSuccessOrFail: null,);}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/back_to_login_in_button.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/back_to_login_in_button.dartnew file mode 100644index 0000000000..2e864ba30c--- /dev/null+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/back_to_login_in_button.dart@@ -0,0 +1,30 @@+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flutter/material.dart';++class BackToLoginButton extends StatelessWidget {+ const BackToLoginButton({+ super.key,+ required this.onTap,+ });++ final VoidCallback onTap;++ @override+ Widget build(BuildContext context) {+ return AFGhostTextButton(+ text: LocaleKeys.signIn_backToLogin.tr(),+ size: AFButtonSize.s,+ onTap: onTap,+ padding: EdgeInsets.zero,+ textColor: (context, isHovering, disabled) {+ final theme = AppFlowyTheme.of(context);+ if (isHovering) {+ return theme.fillColorScheme.themeThickHover;+ }+ return theme.textColorScheme.theme;+ },+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_button.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_button.dartnew file mode 100644index 0000000000..5b7525d318--- /dev/null+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_button.dart@@ -0,0 +1,27 @@+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:flutter/material.dart';++class ContinueWithButton extends StatelessWidget {+ const ContinueWithButton({+ super.key,+ required this.onTap,+ required this.text,+ });++ final VoidCallback onTap;+ final String text;++ @override+ Widget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ return AFFilledTextButton.primary(+ size: AFButtonSize.l,+ alignment: Alignment.center,+ text: text,+ onTap: onTap,+ textStyle: theme.textStyle.body.enhanced(+ color: theme.textColorScheme.onFill,+ ),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_email_and_password.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_email_and_password.dartindex 5027874418..6738f123ce 100644--- a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_email_and_password.dart+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_email_and_password.dart@@ -162,6 +162,7 @@ class _ContinueWithEmailAndPasswordStateNavigator.push(context,MaterialPageRoute(+ settings: const RouteSettings(name: '/continue-with-password'),builder: (context) => BlocProvider.value(value: signInBloc,child: ContinueWithPasswordPage(diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_magic_link_or_passcode_page.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_magic_link_or_passcode_page.dartindex 39e06f6371..7a87c3efd1 100644--- a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_magic_link_or_passcode_page.dart+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_magic_link_or_passcode_page.dart@@ -1,6 +1,9 @@import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/user/application/sign_in_bloc.dart';-import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/logo/logo.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/back_to_login_in_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/title_logo.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/verifying_button.dart';import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';@@ -69,13 +72,15 @@ class _ContinueWithMagicLinkOrPasscodePageStatemainAxisAlignment: MainAxisAlignment.center,children: [// Logo, title and description- ..._buildLogoTitleAndDescription(),+ _buildLogoTitleAndDescription(),// Enter code manually..._buildEnterCodeManually(),// Back to login- ..._buildBackToLogin(),+ BackToLoginButton(+ onTap: widget.backToLogin,+ ),],),),@@ -87,7 +92,6 @@ class _ContinueWithMagicLinkOrPasscodePageStateList<Widget> _buildEnterCodeManually() {// todo: ask designer to provide the spacingfinal spacing = VSpace(20);- final textStyle = AFButtonSize.l.buildTextStyle(context);if (!isEnteringPasscode) {return [@@ -124,155 +128,51 @@ class _ContinueWithMagicLinkOrPasscodePageState// continue to loginisSubmitting- ? _buildIndicator(textStyle: textStyle)- : _buildContinueButton(textStyle: textStyle),+ ? const VerifyingButton()+ : ContinueWithButton(+ text: LocaleKeys.signIn_continueToSignIn.tr(),+ onTap: () {+ final passcode = passcodeController.text;+ if (passcode.isEmpty) {+ inputPasscodeKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_invalidVerificationCode.tr(),+ );+ } else {+ widget.onEnterPasscode(passcode);+ }+ },+ ),spacing,];}- Widget _buildContinueButton({- required TextStyle textStyle,- }) {- return AFFilledTextButton.primary(- text: LocaleKeys.signIn_continueToSignIn.tr(),- onTap: () {- final passcode = passcodeController.text;- if (passcode.isEmpty) {- inputPasscodeKey.currentState?.syncError(- errorText: LocaleKeys.signIn_invalidVerificationCode.tr(),- );- } else {- widget.onEnterPasscode(passcode);- }- },- textStyle: textStyle.copyWith(- color: AppFlowyTheme.of(context).textColorScheme.onFill,- ),- size: AFButtonSize.l,- alignment: Alignment.center,- );- }-- Widget _buildIndicator({- required TextStyle textStyle,- }) {+ Widget _buildLogoTitleAndDescription() {final theme = AppFlowyTheme.of(context);- return Opacity(- opacity: 0.7, // TODO: ask designer to provide the opacity- child: AFFilledButton.disabled(- size: AFButtonSize.l,- backgroundColor: theme.fillColorScheme.themeThick,- builder: (context, isHovering, disabled) {- return Row(- mainAxisAlignment: MainAxisAlignment.center,- children: [- SizedBox.square(- dimension: 15.0,- child: CircularProgressIndicator(- color: theme.textColorScheme.onFill,- strokeWidth: 3.0,- ),- ),- HSpace(theme.spacing.l),- Text(- 'Verifying...',- style: textStyle.copyWith(- color: theme.textColorScheme.onFill,- ),- ),- ],- );- },- ),- );- }- List<Widget> _buildBackToLogin() {- return [- AFGhostTextButton(- text: LocaleKeys.signIn_backToLogin.tr(),- size: AFButtonSize.s,- onTap: widget.backToLogin,- padding: EdgeInsets.zero,- textColor: (context, isHovering, disabled) {- final theme = AppFlowyTheme.of(context);- if (isHovering) {- return theme.fillColorScheme.themeThickHover;- }- return theme.textColorScheme.theme;- },- ),- ];- }-- List<Widget> _buildLogoTitleAndDescription() {- final theme = AppFlowyTheme.of(context);- final spacing = VSpace(theme.spacing.xxl);if (!isEnteringPasscode) {- return [- // logo- const AFLogo(),- spacing,-- // title- Text(- LocaleKeys.signIn_checkYourEmail.tr(),- style: theme.textStyle.heading3.enhanced(- color: theme.textColorScheme.primary,- ),- ),- spacing,-- // description- Text(- LocaleKeys.signIn_temporaryVerificationLinkSent.tr(),- style: theme.textStyle.body.standard(- color: theme.textColorScheme.primary,- ),- textAlign: TextAlign.center,- ),- Text(+ return TitleLogo(+ title: LocaleKeys.signIn_checkYourEmail.tr(),+ description: LocaleKeys.signIn_temporaryVerificationLinkSent.tr(),+ informationBuilder: (context) => Text(widget.email,style: theme.textStyle.body.enhanced(color: theme.textColorScheme.primary,),- textAlign: TextAlign.center,),- spacing,- ];+ );} else {- return [- // logo- const AFLogo(),- spacing,-- // title- Text(- LocaleKeys.signIn_enterCode.tr(),- style: theme.textStyle.heading3.enhanced(- color: theme.textColorScheme.primary,- ),- ),- spacing,-- // description- Text(- LocaleKeys.signIn_temporaryVerificationCodeSent.tr(),- style: theme.textStyle.body.standard(- color: theme.textColorScheme.primary,- ),- textAlign: TextAlign.center,- ),- Text(+ return TitleLogo(+ title: LocaleKeys.signIn_enterCode.tr(),+ description: LocaleKeys.signIn_temporaryVerificationCodeSent.tr(),+ informationBuilder: (context) => Text(widget.email,style: theme.textStyle.body.enhanced(color: theme.textColorScheme.primary,),textAlign: TextAlign.center,),- spacing,- ];+ );}}}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_password.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_password.dartindex 5bfd191e22..4e68748a0c 100644--- a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_password.dart+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_password.dart@@ -1,4 +1,6 @@+import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';import 'package:flutter/material.dart';class ContinueWithPassword extends StatelessWidget {@@ -12,7 +14,7 @@ class ContinueWithPassword extends StatelessWidget {@overrideWidget build(BuildContext context) {return AFOutlinedTextButton.normal(- text: 'Continue with password',+ text: LocaleKeys.signIn_continueWithPassword.tr(),size: AFButtonSize.l,alignment: Alignment.center,onTap: onTap,diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_password_page.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_password_page.dartindex f704169e73..7cbd1d9071 100644--- a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_password_page.dart+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_password_page.dart@@ -1,7 +1,11 @@+import 'package:appflowy/env/cloud_env.dart';import 'package:appflowy/generated/locale_keys.g.dart';import 'package:appflowy/user/application/sign_in_bloc.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/back_to_login_in_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_button.dart';import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/forgot_password_page.dart';-import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/logo/logo.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/title_logo.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/verifying_button.dart';import 'package:appflowy/workspace/presentation/settings/pages/account/password/password_suffix_icon.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';@@ -74,13 +78,15 @@ class _ContinueWithPasswordPageState extends State<ContinueWithPasswordPage> {mainAxisAlignment: MainAxisAlignment.center,children: [// Logo and title- ..._buildLogoAndTitle(),+ _buildLogoAndTitle(),// Password input and buttons..._buildPasswordSection(),// Back to login- ..._buildBackToLogin(),+ BackToLoginButton(+ onTap: widget.backToLogin,+ ),],),),@@ -89,25 +95,12 @@ class _ContinueWithPasswordPageState extends State<ContinueWithPasswordPage> {);}- List<Widget> _buildLogoAndTitle() {+ Widget _buildLogoAndTitle() {final theme = AppFlowyTheme.of(context);- final spacing = VSpace(theme.spacing.xxl);- return [- // logo- const AFLogo(),- spacing,-- // title- Text(- LocaleKeys.signIn_enterPassword.tr(),- style: theme.textStyle.heading3.enhanced(- color: theme.textColorScheme.primary,- ),- ),- spacing,-- // email display- RichText(+ return TitleLogo(+ title: LocaleKeys.signIn_enterPassword.tr(),+ informationBuilder: (context) => // email display+ RichText(text: TextSpan(children: [TextSpan(@@ -125,14 +118,12 @@ class _ContinueWithPasswordPageState extends State<ContinueWithPasswordPage> {],),),- spacing,- ];+ );}List<Widget> _buildPasswordSection() {final theme = AppFlowyTheme.of(context);final iconSize = 20.0;- final textStyle = AFButtonSize.l.buildTextStyle(context);return [// Password input@@ -164,19 +155,7 @@ class _ContinueWithPasswordPageState extends State<ContinueWithPasswordPage> {text: LocaleKeys.signIn_forgotPassword.tr(),size: AFButtonSize.s,padding: EdgeInsets.zero,- onTap: () {- Navigator.push(- context,- MaterialPageRoute(- builder: (context) => ForgotPasswordPage(- email: widget.email,- backToLogin: widget.backToLogin,- onEnterPassword: widget.onEnterPassword,- onForgotPassword: widget.onForgotPassword,- ),- ),- );- },+ onTap: () => _pushForgotPasswordPage(),textStyle: theme.textStyle.body.standard(color: theme.textColorScheme.action,),@@ -189,79 +168,38 @@ class _ContinueWithPasswordPageState extends State<ContinueWithPasswordPage> {},),),- VSpace(20),+ VSpace(theme.spacing.xxl),// Continue buttonisSubmitting- ? _buildIndicator(textStyle: textStyle)- : _buildContinueButton(textStyle: textStyle),+ ? const VerifyingButton()+ : ContinueWithButton(+ text: LocaleKeys.web_continue.tr(),+ onTap: () => widget.onEnterPassword(passwordController.text),+ ),VSpace(20),];}- Widget _buildContinueButton({- required TextStyle textStyle,- }) {- return AFFilledTextButton.primary(- text: LocaleKeys.web_continue.tr(),- textStyle: textStyle.copyWith(- color: AppFlowyTheme.of(context).textColorScheme.onFill,- ),- onTap: () => widget.onEnterPassword(passwordController.text),- size: AFButtonSize.l,- alignment: Alignment.center,- );- }-- Widget _buildIndicator({- required TextStyle textStyle,- }) {- final theme = AppFlowyTheme.of(context);- return Opacity(- opacity: 0.7, // TODO: ask designer to provide the opacity- child: AFFilledButton.disabled(- size: AFButtonSize.l,- backgroundColor: theme.fillColorScheme.themeThick,- builder: (context, isHovering, disabled) {- return Row(- mainAxisAlignment: MainAxisAlignment.center,- children: [- SizedBox.square(- dimension: 15.0,- child: CircularProgressIndicator(- color: theme.textColorScheme.onFill,- strokeWidth: 3.0,- ),- ),- HSpace(theme.spacing.l),- Text(- 'Verifying...',- style: textStyle.copyWith(- color: theme.textColorScheme.onFill,- ),- ),- ],- );- },- ),- );- }-- List<Widget> _buildBackToLogin() {- return [- AFGhostTextButton(- text: LocaleKeys.signIn_backToLogin.tr(),- size: AFButtonSize.s,- onTap: widget.backToLogin,- padding: EdgeInsets.zero,- textColor: (context, isHovering, disabled) {- final theme = AppFlowyTheme.of(context);- if (isHovering) {- return theme.fillColorScheme.themeThickHover;- }- return theme.textColorScheme.theme;- },- ),- ];+ Future<void> _pushForgotPasswordPage() async {+ final signInBloc = context.read<SignInBloc>();+ final baseUrl = await getAppFlowyCloudUrl();++ if (mounted && context.mounted) {+ await Navigator.push(+ context,+ MaterialPageRoute(+ settings: const RouteSettings(name: '/forgot-password'),+ builder: (context) => BlocProvider.value(+ value: signInBloc,+ child: ForgotPasswordPage(+ email: widget.email,+ backToLogin: widget.backToLogin,+ baseUrl: baseUrl,+ ),+ ),+ ),+ );+ }}}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/forgot_password_page.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/forgot_password_page.dartindex de1007864c..28757b5b90 100644--- a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/forgot_password_page.dart+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/forgot_password_page.dart@@ -1,27 +1,30 @@import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/user/application/password/password_http_service.dart';import 'package:appflowy/user/application/sign_in_bloc.dart';-import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/logo/logo.dart';-import 'package:appflowy/workspace/presentation/settings/pages/account/password/password_suffix_icon.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/back_to_login_in_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/reset_password_page.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/title_logo.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/verifying_button.dart';import 'package:appflowy_ui/appflowy_ui.dart';import 'package:easy_localization/easy_localization.dart';import 'package:flowy_infra_ui/flowy_infra_ui.dart';import 'package:flowy_infra_ui/widget/spacing.dart';import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';+import 'package:string_validator/string_validator.dart';class ForgotPasswordPage extends StatefulWidget {const ForgotPasswordPage({super.key,required this.backToLogin,required this.email,- required this.onEnterPassword,- required this.onForgotPassword,+ required this.baseUrl,});final String email;final VoidCallback backToLogin;- final ValueChanged<String> onEnterPassword;- final VoidCallback onForgotPassword;+ final String baseUrl;@overrideState<ForgotPasswordPage> createState() => _ForgotPasswordPageState();@@ -33,6 +36,19 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {bool isSubmitting = false;+ late final PasswordHttpService forgotPasswordService = PasswordHttpService(+ baseUrl: widget.baseUrl,+ // leave the auth token empty, the user is not signed in yet+ authToken: '',+ );++ @override+ void initState() {+ super.initState();++ passwordController.text = widget.email;+ }+@overridevoid dispose() {passwordController.dispose();@@ -72,13 +88,15 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {mainAxisAlignment: MainAxisAlignment.center,children: [// Logo and title- ..._buildLogoAndTitle(),+ _buildLogoAndTitle(),// Password input and buttons..._buildPasswordSection(),// Back to login- ..._buildBackToLogin(),+ BackToLoginButton(+ onTap: widget.backToLogin,+ ),],),),@@ -87,58 +105,16 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {);}- List<Widget> _buildLogoAndTitle() {- final theme = AppFlowyTheme.of(context);- final spacing = VSpace(theme.spacing.xxl);- return [- // logo- const AFLogo(),- spacing,-- // title- Text(- LocaleKeys.signIn_enterPassword.tr(),- style: theme.textStyle.heading3.enhanced(- color: theme.textColorScheme.primary,- ),- ),- spacing,-- // email display- RichText(- text: TextSpan(- children: [- TextSpan(- text: LocaleKeys.signIn_loginAs.tr(),- style: theme.textStyle.body.standard(- color: theme.textColorScheme.primary,- ),- ),- TextSpan(- text: ' ${widget.email}',- style: theme.textStyle.body.enhanced(- color: theme.textColorScheme.primary,- ),- ),- ],- ),- ),- spacing,- ];+ Widget _buildLogoAndTitle() {+ return TitleLogo(+ title: LocaleKeys.signIn_resetPassword.tr(),+ description: LocaleKeys.signIn_resetPasswordDescription.tr(),+ );}List<Widget> _buildPasswordSection() {final theme = AppFlowyTheme.of(context);final iconSize = 20.0;- final textStyle = AFButtonSize.l.buildTextStyle(context);- final textHeight = textStyle.height;- final textFontSize = textStyle.fontSize;-- // the indicator height is the height of the text style.- double indicatorHeight = 20;- if (textHeight != null && textFontSize != null) {- indicatorHeight = textHeight * textFontSize;- }return [// Password input@@ -147,99 +123,70 @@ class _ForgotPasswordPageState extends State<ForgotPasswordPage> {controller: passwordController,hintText: LocaleKeys.signIn_enterPassword.tr(),autoFocus: true,- obscureText: true,suffixIconConstraints: BoxConstraints.tightFor(width: iconSize + theme.spacing.m,height: iconSize,),- suffixIconBuilder: (context, isObscured) => PasswordSuffixIcon(- isObscured: isObscured,- onTap: () {- inputPasswordKey.currentState?.syncObscured(!isObscured);- },- ),- onSubmitted: widget.onEnterPassword,+ onSubmitted: (_) => _onSubmit(),),- // todo: ask designer to provide the spacing- VSpace(8),-- // Forgot password button- Align(- alignment: Alignment.centerLeft,- child: AFGhostTextButton(- text: LocaleKeys.signIn_forgotPassword.tr(),- size: AFButtonSize.s,- padding: EdgeInsets.zero,- onTap: widget.onForgotPassword,- textStyle: theme.textStyle.body.standard(- color: theme.textColorScheme.action,- ),- textColor: (context, isHovering, disabled) {- final theme = AppFlowyTheme.of(context);- if (isHovering) {- return theme.fillColorScheme.themeThickHover;- }- return theme.textColorScheme.theme;- },- ),- ),- VSpace(20),++ VSpace(theme.spacing.xxl),// Continue buttonisSubmitting- ? _buildIndicator(indicatorHeight: indicatorHeight)- : _buildContinueButton(textStyle: textStyle),- VSpace(20),+ ? const VerifyingButton()+ : ContinueWithButton(+ text: LocaleKeys.button_submit.tr(),+ onTap: _onSubmit,+ ),+ VSpace(theme.spacing.xxl),];}- Widget _buildContinueButton({- required TextStyle textStyle,- }) {- return AFFilledTextButton.primary(- text: LocaleKeys.web_continue.tr(),- textStyle: textStyle.copyWith(- color: AppFlowyTheme.of(context).textColorScheme.onFill,- ),- onTap: () => widget.onEnterPassword(passwordController.text),- size: AFButtonSize.l,- alignment: Alignment.center,- );- }+ Future<void> _onSubmit() async {+ final email = passwordController.text;+ if (!isEmail(email)) {+ inputPasswordKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_invalidEmail.tr(),+ );+ return;+ }- Widget _buildIndicator({- required double indicatorHeight,- }) {- return AFFilledButton.disabled(- size: AFButtonSize.l,- builder: (context, isHovering, disabled) {- return Align(- child: SizedBox.square(- dimension: indicatorHeight,- child: CircularProgressIndicator(- strokeWidth: 3.0,+ final signInBloc = context.read<SignInBloc>();++ setState(() {+ isSubmitting = true;+ });++ final result = await forgotPasswordService.forgotPassword(email: email);++ setState(() {+ isSubmitting = false;+ });++ result.fold(+ (success) {+ // push the email to the next screen+ Navigator.push(+ context,+ MaterialPageRoute(+ settings: const RouteSettings(name: '/reset-password'),+ builder: (context) => BlocProvider.value(+ value: signInBloc,+ child: ResetPasswordPage(+ email: email,+ backToLogin: widget.backToLogin,+ baseUrl: widget.baseUrl,+ ),),),);},+ (error) {+ inputPasswordKey.currentState?.syncError(+ errorText: error.toString(),+ );+ },);}-- List<Widget> _buildBackToLogin() {- return [- AFGhostTextButton(- text: LocaleKeys.signIn_backToLogin.tr(),- size: AFButtonSize.s,- onTap: widget.backToLogin,- padding: EdgeInsets.zero,- textColor: (context, isHovering, disabled) {- final theme = AppFlowyTheme.of(context);- if (isHovering) {- return theme.fillColorScheme.themeThickHover;- }- return theme.textColorScheme.theme;- },- ),- ];- }}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/reset_password.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/reset_password.dartnew file mode 100644index 0000000000..903260862a--- /dev/null+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/reset_password.dart@@ -0,0 +1,175 @@+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/user/application/sign_in_bloc.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/back_to_login_in_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/title_logo.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/verifying_button.dart';+import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/widget/spacing.dart';+import 'package:flutter/material.dart';+import 'package:flutter_bloc/flutter_bloc.dart';++class ResetPasswordWidget extends StatefulWidget {+ const ResetPasswordWidget({+ super.key,+ required this.backToLogin,+ required this.email,+ required this.baseUrl,+ required this.onValidateResetPasswordToken,+ });++ final String email;+ final VoidCallback backToLogin;+ final String baseUrl;+ final ValueChanged<bool> onValidateResetPasswordToken;++ @override+ State<ResetPasswordWidget> createState() => _ResetPasswordWidgetState();+}++class _ResetPasswordWidgetState extends State<ResetPasswordWidget> {+ final passcodeController = TextEditingController();++ ToastificationItem? toastificationItem;++ final inputPasscodeKey = GlobalKey<AFTextFieldState>();++ bool isSubmitting = false;++ @override+ void dispose() {+ passcodeController.dispose();++ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ return BlocConsumer<SignInBloc, SignInState>(+ listener: (context, state) {+ final successOrFail = state.validateResetPasswordTokenSuccessOrFail;+ if (successOrFail != null) {+ successOrFail.fold(+ (success) {+ widget.onValidateResetPasswordToken(true);+ },+ (error) {+ widget.onValidateResetPasswordToken(false);+ inputPasscodeKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_resetPasswordFailed.tr(),+ );+ },+ );+ }++ if (state.isSubmitting != isSubmitting) {+ setState(() => isSubmitting = state.isSubmitting);+ }+ },+ builder: (context, state) {+ return Scaffold(+ body: Center(+ child: SizedBox(+ width: 320,+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ // Logo, title and description+ _buildLogoTitleAndDescription(),++ // Enter code manually+ ..._buildEnterCodeManually(),++ // Back to login+ BackToLoginButton(+ onTap: widget.backToLogin,+ ),+ ],+ ),+ ),+ ),+ );+ },+ );+ }++ List<Widget> _buildEnterCodeManually() {+ // todo: ask designer to provide the spacing+ final spacing = VSpace(20);++ return [+ // Enter code manually+ AFTextField(+ key: inputPasscodeKey,+ controller: passcodeController,+ hintText: LocaleKeys.signIn_enterCode.tr(),+ keyboardType: TextInputType.number,+ autoFocus: true,+ onSubmitted: (passcode) {+ if (passcode.isEmpty) {+ inputPasscodeKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_invalidVerificationCode.tr(),+ );+ } else {+ //+ }+ },+ ),+ // todo: ask designer to provide the spacing+ VSpace(12),++ // continue to login+ isSubmitting+ ? const VerifyingButton()+ : ContinueWithButton(+ text: LocaleKeys.signIn_continueToResetPassword.tr(),+ onTap: () {+ final passcode = passcodeController.text;+ if (passcode.isEmpty) {+ inputPasscodeKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_invalidVerificationCode.tr(),+ );+ } else {+ _onSubmit();+ }+ },+ ),++ spacing,+ ];+ }++ Widget _buildLogoTitleAndDescription() {+ final theme = AppFlowyTheme.of(context);+ return TitleLogo(+ title: LocaleKeys.signIn_checkYourEmail.tr(),+ description: LocaleKeys.signIn_temporaryVerificationLinkSent.tr(),+ informationBuilder: (context) => Text(+ widget.email,+ style: theme.textStyle.body.enhanced(+ color: theme.textColorScheme.primary,+ ),+ textAlign: TextAlign.center,+ ),+ );+ }++ Future<void> _onSubmit() async {+ final passcode = passcodeController.text;+ if (passcode.isEmpty) {+ inputPasscodeKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_invalidVerificationCode.tr(),+ );+ return;+ }++ context.read<SignInBloc>().add(+ ValidateResetPasswordToken(+ email: widget.email,+ token: passcode,+ ),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/reset_password_page.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/reset_password_page.dartnew file mode 100644index 0000000000..92268418da--- /dev/null+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/reset_password_page.dart@@ -0,0 +1,53 @@+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/reset_password.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/set_new_password.dart';+import 'package:flutter/material.dart';++enum ResetPasswordPageState {+ enterPasscode,+ setNewPassword,+}++class ResetPasswordPage extends StatefulWidget {+ const ResetPasswordPage({+ super.key,+ required this.backToLogin,+ required this.email,+ required this.baseUrl,+ });++ final String email;+ final VoidCallback backToLogin;+ final String baseUrl;++ @override+ State<ResetPasswordPage> createState() => _ResetPasswordPageState();+}++class _ResetPasswordPageState extends State<ResetPasswordPage> {+ ResetPasswordPageState state = ResetPasswordPageState.enterPasscode;++ @override+ void dispose() {+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ return switch (state) {+ ResetPasswordPageState.enterPasscode => ResetPasswordWidget(+ email: widget.email,+ backToLogin: widget.backToLogin,+ baseUrl: widget.baseUrl,+ onValidateResetPasswordToken: (isValid) {+ setState(() {+ state = ResetPasswordPageState.setNewPassword;+ });+ },+ ),+ ResetPasswordPageState.setNewPassword => SetNewPasswordWidget(+ backToLogin: widget.backToLogin,+ email: widget.email,+ ),+ };+ }+}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/set_new_password.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/set_new_password.dartnew file mode 100644index 0000000000..ecacad5903--- /dev/null+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/set_new_password.dart@@ -0,0 +1,205 @@+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy/user/application/sign_in_bloc.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/back_to_login_in_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/continue_with_button.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/title_logo.dart';+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/continue_with/verifying_button.dart';+import 'package:appflowy/workspace/presentation/widgets/dialogs.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/widget/spacing.dart';+import 'package:flutter/material.dart';+import 'package:flutter_bloc/flutter_bloc.dart';++class SetNewPasswordWidget extends StatefulWidget {+ const SetNewPasswordWidget({+ super.key,+ required this.backToLogin,+ required this.email,+ });++ final String email;+ final VoidCallback backToLogin;++ @override+ State<SetNewPasswordWidget> createState() => _SetNewPasswordWidgetState();+}++class _SetNewPasswordWidgetState extends State<SetNewPasswordWidget> {+ final newPasswordController = TextEditingController();+ final confirmPasswordController = TextEditingController();++ final newPasswordKey = GlobalKey<AFTextFieldState>();+ final confirmPasswordKey = GlobalKey<AFTextFieldState>();++ bool isSubmitting = false;++ @override+ void dispose() {+ newPasswordController.dispose();+ confirmPasswordController.dispose();+ super.dispose();+ }++ @override+ Widget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ final spacing = theme.spacing.xxl;+ return BlocConsumer<SignInBloc, SignInState>(+ listener: (context, state) {+ final successOrFail = state.resetPasswordSuccessOrFail;+ if (successOrFail != null) {+ successOrFail.fold(+ (success) {+ showToastNotification(+ message: LocaleKeys.signIn_resetPasswordSuccess.tr(),+ );+ // pop until the login screen is found+ Navigator.popUntil(context, (route) {+ return route.settings.name == '/continue-with-password';+ });+ },+ (error) {+ newPasswordKey.currentState?.syncError(+ errorText: error.msg,+ );+ },+ );+ }+ // Handle state changes and validation results here+ if (state.isSubmitting != isSubmitting) {+ setState(() => isSubmitting = state.isSubmitting);+ }+ },+ builder: (context, state) {+ return Scaffold(+ body: Center(+ child: SizedBox(+ width: 320,+ child: Column(+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ _buildLogoAndTitle(),+ _buildPasswordFields(),+ VSpace(spacing),+ _buildResetButton(),+ VSpace(spacing),+ BackToLoginButton(+ onTap: widget.backToLogin,+ ),+ ],+ ),+ ),+ ),+ );+ },+ );+ }++ Widget _buildLogoAndTitle() {+ final theme = AppFlowyTheme.of(context);+ return TitleLogo(+ title: LocaleKeys.signIn_resetPassword.tr(),+ informationBuilder: (context) => RichText(+ text: TextSpan(+ children: [+ TextSpan(+ text: LocaleKeys.signIn_enterNewPasswordFor.tr(),+ style: theme.textStyle.body.standard(+ color: theme.textColorScheme.primary,+ ),+ ),+ TextSpan(+ text: widget.email,+ style: theme.textStyle.body.enhanced(+ color: theme.textColorScheme.primary,+ ),+ ),+ ],+ ),+ textAlign: TextAlign.center,+ ),+ );+ }++ Widget _buildPasswordFields() {+ final theme = AppFlowyTheme.of(context);+ return Column(+ crossAxisAlignment: CrossAxisAlignment.start,+ children: [+ Text(+ LocaleKeys.signIn_newPassword.tr(),+ style: theme.textStyle.caption.enhanced(+ color: theme.textColorScheme.secondary,+ ),+ ),+ const VSpace(8),+ AFTextField(+ key: newPasswordKey,+ controller: newPasswordController,+ obscureText: true,+ hintText: LocaleKeys.signIn_enterNewPassword.tr(),+ onSubmitted: (_) => _validateAndSubmit(),+ ),+ const VSpace(16),+ Text(+ LocaleKeys.signIn_confirmPassword.tr(),+ style: theme.textStyle.caption.enhanced(+ color: theme.textColorScheme.secondary,+ ),+ ),+ const VSpace(8),+ AFTextField(+ key: confirmPasswordKey,+ controller: confirmPasswordController,+ obscureText: true,+ hintText: LocaleKeys.signIn_confirmNewPassword.tr(),+ onSubmitted: (_) => _validateAndSubmit(),+ ),+ ],+ );+ }++ Widget _buildResetButton() {+ return isSubmitting+ ? const VerifyingButton()+ : ContinueWithButton(+ text: LocaleKeys.signIn_resetPassword.tr(),+ onTap: _validateAndSubmit,+ );+ }++ void _validateAndSubmit() {+ final newPassword = newPasswordController.text;+ final confirmPassword = confirmPasswordController.text;++ if (newPassword.isEmpty) {+ newPasswordKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_newPasswordCannotBeEmpty.tr(),+ );+ return;+ }++ if (confirmPassword.isEmpty) {+ confirmPasswordKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_confirmPasswordCannotBeEmpty.tr(),+ );+ return;+ }++ if (newPassword != confirmPassword) {+ confirmPasswordKey.currentState?.syncError(+ errorText: LocaleKeys.signIn_passwordsDoNotMatch.tr(),+ );+ return;+ }++ // Add the reset password event to the bloc+ context.read<SignInBloc>().add(+ ResetPassword(+ email: widget.email,+ newPassword: newPassword,+ ),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/title_logo.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/title_logo.dartnew file mode 100644index 0000000000..3c6691753d--- /dev/null+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/title_logo.dart@@ -0,0 +1,54 @@+import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/logo/logo.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:flowy_infra_ui/widget/spacing.dart';+import 'package:flutter/material.dart';++class TitleLogo extends StatelessWidget {+ const TitleLogo({+ super.key,+ required this.title,+ this.description,+ this.informationBuilder,+ });++ final String title;+ final String? description;+ final WidgetBuilder? informationBuilder;++ @override+ Widget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ final spacing = VSpace(theme.spacing.xxl);++ return Column(+ children: [+ // logo+ const AFLogo(),+ spacing,++ // title+ Text(+ title,+ style: theme.textStyle.heading3.enhanced(+ color: theme.textColorScheme.primary,+ ),+ ),+ spacing,++ // description+ if (description != null)+ Text(+ description!,+ style: theme.textStyle.body.standard(+ color: theme.textColorScheme.primary,+ ),+ textAlign: TextAlign.center,+ ),++ if (informationBuilder != null) informationBuilder!(context),++ spacing,+ ],+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/verifying_button.dart b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/verifying_button.dartnew file mode 100644index 0000000000..446eb467db--- /dev/null+++ b/frontend/appflowy_flutter/lib/user/presentation/screens/sign_in_screen/widgets/continue_with/verifying_button.dart@@ -0,0 +1,42 @@+import 'package:appflowy/generated/locale_keys.g.dart';+import 'package:appflowy_ui/appflowy_ui.dart';+import 'package:easy_localization/easy_localization.dart';+import 'package:flowy_infra_ui/widget/spacing.dart';+import 'package:flutter/material.dart';++class VerifyingButton extends StatelessWidget {+ const VerifyingButton({super.key});++ @override+ Widget build(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ return Opacity(+ opacity: 0.7,+ child: AFFilledButton.disabled(+ size: AFButtonSize.l,+ backgroundColor: theme.fillColorScheme.themeThick,+ builder: (context, isHovering, disabled) {+ return Row(+ mainAxisAlignment: MainAxisAlignment.center,+ children: [+ SizedBox.square(+ dimension: 15.0,+ child: CircularProgressIndicator(+ color: theme.textColorScheme.onFill,+ strokeWidth: 3.0,+ ),+ ),+ HSpace(theme.spacing.l),+ Text(+ LocaleKeys.signIn_verifying.tr(),+ style: theme.textStyle.body.enhanced(+ color: theme.textColorScheme.onFill,+ ),+ ),+ ],+ );+ },+ ),+ );+ }+}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/password/change_password.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/password/change_password.dartindex b7e3661870..e865da79f0 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/password/change_password.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/password/change_password.dart@@ -14,10 +14,25 @@ class ChangePasswordDialogContent extends StatefulWidget {const ChangePasswordDialogContent({super.key,required this.userProfile,+ this.showTitle = true,+ this.showCloseAndSaveButton = true,+ this.showSaveButton = false,+ this.padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 16),});final UserProfilePB userProfile;+ // display the title+ final bool showTitle;++ // display the desktop style close and save button+ final bool showCloseAndSaveButton;++ // display the mobile style save button+ final bool showSaveButton;++ final EdgeInsets padding;+@overrideState<ChangePasswordDialogContent> createState() =>_ChangePasswordDialogContentState();@@ -50,7 +65,7 @@ class _ChangePasswordDialogContentStatereturn BlocListener<PasswordBloc, PasswordState>(listener: _onPasswordStateChanged,child: Container(- padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),+ padding: widget.padding,constraints: const BoxConstraints(maxWidth: 400),decoration: BoxDecoration(borderRadius: BorderRadius.circular(theme.borderRadius.xl),@@ -59,15 +74,22 @@ class _ChangePasswordDialogContentStatemainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start,children: [- _buildTitle(context),- VSpace(theme.spacing.l),+ if (widget.showTitle) ...[+ _buildTitle(context),+ VSpace(theme.spacing.xl),+ ],..._buildCurrentPasswordFields(context),- VSpace(theme.spacing.l),+ VSpace(theme.spacing.xl),..._buildNewPasswordFields(context),- VSpace(theme.spacing.l),+ VSpace(theme.spacing.xl),..._buildConfirmPasswordFields(context),- VSpace(theme.spacing.l),- _buildSubmitButton(context),+ VSpace(theme.spacing.xl),+ if (widget.showCloseAndSaveButton) ...[+ _buildSubmitButton(context),+ ],+ if (widget.showSaveButton) ...[+ _buildSaveButton(context),+ ],],),),@@ -221,6 +243,19 @@ class _ChangePasswordDialogContentState);}+ Widget _buildSaveButton(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ return AFFilledTextButton.primary(+ text: LocaleKeys.button_save.tr(),+ textStyle: theme.textStyle.body.standard(+ color: theme.textColorScheme.onFill,+ ),+ size: AFButtonSize.l,+ alignment: Alignment.center,+ onTap: () => _save(context),+ );+ }+void _save(BuildContext context) async {_resetError();@@ -291,7 +326,6 @@ class _ChangePasswordDialogContentStatevoid _onPasswordStateChanged(BuildContext context, PasswordState state) {bool hasError = false;String message = '';- String description = '';final changePasswordResult = state.changePasswordResult;final setPasswordResult = state.setupPasswordResult;@@ -308,7 +342,20 @@ class _ChangePasswordDialogContentStatemessage = LocaleKeys.newSettings_myAccount_password_toast_passwordUpdatedFailed.tr();- description = error.msg;+ if (error.msg.contains('Incorrect current password')) {+ currentPasswordTextFieldKey.currentState?.syncError(+ errorText: LocaleKeys+ .newSettings_myAccount_password_error_currentPasswordIsIncorrect+ .tr(),+ );+ } else if (error.msg+ .contains('Password should be at least 6 characters.')) {+ newPasswordTextFieldKey.currentState?.syncError(+ errorText: LocaleKeys+ .newSettings_myAccount_password_error_passwordShouldBeAtLeast6Characters+ .tr(),+ );+ }},);} else if (setPasswordResult != null) {@@ -323,17 +370,16 @@ class _ChangePasswordDialogContentStatemessage = LocaleKeys.newSettings_myAccount_password_toast_passwordSetupFailed.tr();- description = error.msg;},);}if (!state.isSubmitting && message.isNotEmpty) {- showToastNotification(- message: message,- description: description,- type: hasError ? ToastificationType.error : ToastificationType.success,- );+ if (!hasError) {+ showToastNotification(+ message: message,+ );+ }if (!hasError) {Navigator.of(context).pop();diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/password/setup_password.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/password/setup_password.dartindex c4f6a02b2d..cf839a7327 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/password/setup_password.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/pages/account/password/setup_password.dart@@ -14,10 +14,26 @@ class SetupPasswordDialogContent extends StatefulWidget {const SetupPasswordDialogContent({super.key,required this.userProfile,+ this.showCloseAndSaveButton = true,+ this.showSaveButton = false,+ this.showTitle = true,+ this.padding = const EdgeInsets.symmetric(horizontal: 20, vertical: 16),});final UserProfilePB userProfile;+ // display the desktop style close and save button+ final bool showCloseAndSaveButton;++ // display the mobile style save button+ final bool showSaveButton;++ // display the title+ final bool showTitle;++ // padding+ final EdgeInsets padding;+@overrideState<SetupPasswordDialogContent> createState() =>_SetupPasswordDialogContentState();@@ -46,7 +62,7 @@ class _SetupPasswordDialogContentStatereturn BlocListener<PasswordBloc, PasswordState>(listener: _onPasswordStateChanged,child: Container(- padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),+ padding: widget.padding,constraints: const BoxConstraints(maxWidth: 400),decoration: BoxDecoration(borderRadius: BorderRadius.circular(theme.borderRadius.xl),@@ -55,13 +71,20 @@ class _SetupPasswordDialogContentStatemainAxisSize: MainAxisSize.min,crossAxisAlignment: CrossAxisAlignment.start,children: [- _buildTitle(context),- VSpace(theme.spacing.l),+ if (widget.showTitle) ...[+ _buildTitle(context),+ VSpace(theme.spacing.xl),+ ],..._buildPasswordFields(context),- VSpace(theme.spacing.l),+ VSpace(theme.spacing.xl),..._buildConfirmPasswordFields(context),- VSpace(theme.spacing.l),- _buildSubmitButton(context),+ VSpace(theme.spacing.xl),+ if (widget.showCloseAndSaveButton) ...[+ _buildSubmitButton(context),+ ],+ if (widget.showSaveButton) ...[+ _buildSaveButton(context),+ ],],),),@@ -183,6 +206,19 @@ class _SetupPasswordDialogContentState);}+ Widget _buildSaveButton(BuildContext context) {+ final theme = AppFlowyTheme.of(context);+ return AFFilledTextButton.primary(+ text: LocaleKeys.button_save.tr(),+ textStyle: theme.textStyle.body.standard(+ color: theme.textColorScheme.onFill,+ ),+ size: AFButtonSize.l,+ alignment: Alignment.center,+ onTap: () => _save(context),+ );+ }+void _save(BuildContext context) async {_resetError();diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/member_http_service.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/member_http_service.dartindex 6975029bba..dd8dae7d2e 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/member_http_service.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/inivitation/member_http_service.dart@@ -185,8 +185,6 @@ class MemberHttpService {);}} catch (e) {- Log.error('${endpoint.name} request failed: error: $e');-return FlowyResult.failure(FlowyError(msg: 'Network error: ${e.toString()}'),);diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_bloc.dartindex 98f94cd54e..8f006ce09b 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_bloc.dart@@ -12,6 +12,7 @@ import 'package:appflowy_backend/protobuf/flowy-error/errors.pb.dart';import 'package:appflowy_backend/protobuf/flowy-user/protobuf.dart';import 'package:appflowy_result/appflowy_result.dart';import 'package:collection/collection.dart';+import 'package:flutter/material.dart';import 'package:flutter_bloc/flutter_bloc.dart';import 'package:freezed_annotation/freezed_annotation.dart';import 'package:protobuf/protobuf.dart';@@ -52,6 +53,7 @@ class WorkspaceMemberBlocupdateSubscriptionInfo: (info) async =>_onUpdateSubscriptionInfo(emit, info),upgradePlan: () async => _onUpgradePlan(),+ getInviteCode: () async => _onGetInviteCode(emit),updateInviteLink: (inviteLink) async => emit(state.copyWith(inviteLink: inviteLink,@@ -61,19 +63,40 @@ class WorkspaceMemberBloc});}+ @override+ Future<void> close() async {+ _workspaceId.dispose();++ await super.close();+ }+final UserProfilePB userProfile;final UserWorkspacePB? workspace;- late final String _workspaceId;final UserBackendService _userBackendService;++ final ValueNotifier<String?> _workspaceId = ValueNotifier<String?>(null);MemberHttpService? _memberHttpService;Future<void> _onInitial(Emitter<WorkspaceMemberState> emit,String? workspaceId,) async {+ _workspaceId.addListener(() {+ if (!isClosed) {+ add(const WorkspaceMemberEvent.getInviteCode());+ }+ });+await _setCurrentWorkspaceId(workspaceId);- final result = await _userBackendService.getWorkspaceMembers(_workspaceId);+ final currentWorkspaceId = _workspaceId.value;+ if (currentWorkspaceId == null) {+ Log.error('Failed to get workspace members: workspaceId is null');+ return;+ }++ final result =+ await _userBackendService.getWorkspaceMembers(currentWorkspaceId);final members = result.fold<List<WorkspaceMemberPB>>((s) => s.items,(e) => [],@@ -84,26 +107,6 @@ class WorkspaceMemberBlocunawaited(_fetchWorkspaceSubscriptionInfo());}- final baseUrl = await getAppFlowyCloudUrl();- final authToken = userProfile.authToken;- if (authToken != null) {- _memberHttpService = MemberHttpService(- baseUrl: baseUrl,- authToken: authToken,- );- unawaited(- _memberHttpService?.getInviteCode(workspaceId: _workspaceId).fold(- (s) async {- final inviteLink = await _buildInviteLink(inviteCode: s);- add(WorkspaceMemberEvent.updateInviteLink(inviteLink));- },- (e) => Log.info('Failed to get invite code: ${e.msg}', e),- ),- );- } else {- Log.error('Failed to get auth token');- }-emit(state.copyWith(members: members,@@ -120,7 +123,13 @@ class WorkspaceMemberBlocFuture<void> _onGetWorkspaceMembers(Emitter<WorkspaceMemberState> emit,) async {- final result = await _userBackendService.getWorkspaceMembers(_workspaceId);+ final workspaceId = _workspaceId.value;+ if (workspaceId == null) {+ Log.error('Failed to get workspace members: workspaceId is null');+ return;+ }++ final result = await _userBackendService.getWorkspaceMembers(workspaceId);final members = result.fold<List<WorkspaceMemberPB>>((s) => s.items,(e) => [],@@ -142,8 +151,14 @@ class WorkspaceMemberBlocEmitter<WorkspaceMemberState> emit,String email,) async {+ final workspaceId = _workspaceId.value;+ if (workspaceId == null) {+ Log.error('Failed to add workspace member by email: workspaceId is null');+ return;+ }+final result = await _userBackendService.addWorkspaceMember(- _workspaceId,+ workspaceId,email,);emit(@@ -165,8 +180,16 @@ class WorkspaceMemberBlocEmitter<WorkspaceMemberState> emit,String email,) async {+ final workspaceId = _workspaceId.value;+ if (workspaceId == null) {+ Log.error(+ 'Failed to invite workspace member by email: workspaceId is null',+ );+ return;+ }+final result = await _userBackendService.inviteWorkspaceMember(- _workspaceId,+ workspaceId,email,role: AFRolePB.Member,);@@ -184,8 +207,16 @@ class WorkspaceMemberBlocEmitter<WorkspaceMemberState> emit,String email,) async {+ final workspaceId = _workspaceId.value;+ if (workspaceId == null) {+ Log.error(+ 'Failed to remove workspace member by email: workspaceId is null',+ );+ return;+ }+final result = await _userBackendService.removeWorkspaceMember(- _workspaceId,+ workspaceId,email,);final members = result.fold(@@ -209,8 +240,14 @@ class WorkspaceMemberBloc) async {}Future<void> _onGenerateInviteLink(Emitter<WorkspaceMemberState> emit) async {+ final workspaceId = _workspaceId.value;+ if (workspaceId == null) {+ Log.error('Failed to generate invite link: workspaceId is null');+ return;+ }+final result = await _memberHttpService?.generateInviteCode(- workspaceId: _workspaceId,+ workspaceId: workspaceId,);await result?.fold(@@ -245,8 +282,14 @@ class WorkspaceMemberBlocString email,AFRolePB role,) async {+ final workspaceId = _workspaceId.value;+ if (workspaceId == null) {+ Log.error('Failed to update workspace member: workspaceId is null');+ return;+ }+final result = await _userBackendService.updateWorkspaceMember(- _workspaceId,+ workspaceId,email,role,);@@ -279,6 +322,12 @@ class WorkspaceMemberBloc}Future<void> _onUpgradePlan() async {+ final workspaceId = _workspaceId.value;+ if (workspaceId == null) {+ Log.error('Failed to upgrade plan: workspaceId is null');+ return;+ }+final plan = state.subscriptionInfo?.plan;if (plan == null) {return Log.error('Failed to upgrade plan: plan is null');@@ -286,7 +335,7 @@ class WorkspaceMemberBlocif (plan == WorkspacePlanPB.FreePlan) {final checkoutLink = await _userBackendService.createSubscription(- _workspaceId,+ workspaceId,SubscriptionPlanPB.Pro,);@@ -297,6 +346,29 @@ class WorkspaceMemberBloc}}+ Future<void> _onGetInviteCode(Emitter<WorkspaceMemberState> emit) async {+ final baseUrl = await getAppFlowyCloudUrl();+ final authToken = userProfile.authToken;+ final workspaceId = _workspaceId.value;+ if (authToken != null && workspaceId != null) {+ _memberHttpService = MemberHttpService(+ baseUrl: baseUrl,+ authToken: authToken,+ );+ unawaited(+ _memberHttpService?.getInviteCode(workspaceId: workspaceId).fold(+ (s) async {+ final inviteLink = await _buildInviteLink(inviteCode: s);+ add(WorkspaceMemberEvent.updateInviteLink(inviteLink));+ },+ (e) => Log.info('Failed to get invite code: ${e.msg}', e),+ ),+ );+ } else {+ Log.error('Failed to get auth token');+ }+ }+AFRolePB _getMyRole(List<WorkspaceMemberPB> members) {final role = members.firstWhereOrNull(@@ -312,24 +384,30 @@ class WorkspaceMemberBlocFuture<void> _setCurrentWorkspaceId(String? workspaceId) async {if (workspace != null) {- _workspaceId = workspace!.workspaceId;+ _workspaceId.value = workspace!.workspaceId;} else if (workspaceId != null && workspaceId.isNotEmpty) {- _workspaceId = workspaceId;+ _workspaceId.value = workspaceId;} else {final currentWorkspace = await FolderEventReadCurrentWorkspace().send();currentWorkspace.fold((s) {- _workspaceId = s.id;+ _workspaceId.value = s.id;}, (e) {assert(false, 'Failed to read current workspace: $e');Log.error('Failed to read current workspace: $e');- _workspaceId = '';});}}Future<void> _fetchWorkspaceSubscriptionInfo() async {- final result =- await UserBackendService.getWorkspaceSubscriptionInfo(_workspaceId);+ final workspaceId = _workspaceId.value;+ if (workspaceId == null) {+ Log.error('Failed to fetch subscription info: workspaceId is null');+ return;+ }++ final result = await UserBackendService.getWorkspaceSubscriptionInfo(+ workspaceId,+ );result.fold((info) {@@ -354,6 +432,8 @@ class WorkspaceMemberBloc@freezedclass WorkspaceMemberEvent with _$WorkspaceMemberEvent {const factory WorkspaceMemberEvent.initial() = Initial;++ // Members related eventsconst factory WorkspaceMemberEvent.getWorkspaceMembers() =GetWorkspaceMembers;const factory WorkspaceMemberEvent.addWorkspaceMember(String email) =@@ -364,19 +444,23 @@ class WorkspaceMemberEvent with _$WorkspaceMemberEvent {const factory WorkspaceMemberEvent.removeWorkspaceMemberByEmail(String email,) = RemoveWorkspaceMemberByEmail;- const factory WorkspaceMemberEvent.inviteWorkspaceMemberByLink(String link) =- InviteWorkspaceMemberByLink;- const factory WorkspaceMemberEvent.generateInviteLink() = GenerateInviteLink;const factory WorkspaceMemberEvent.updateWorkspaceMember(String email,AFRolePB role,) = UpdateWorkspaceMember;++ // Subscription related eventsconst factory WorkspaceMemberEvent.updateSubscriptionInfo(WorkspaceSubscriptionInfoPB subscriptionInfo,) = UpdateSubscriptionInfo;-const factory WorkspaceMemberEvent.upgradePlan() = UpgradePlan;+ // Invite link related events+ const factory WorkspaceMemberEvent.inviteWorkspaceMemberByLink(+ String link,+ ) = InviteWorkspaceMemberByLink;+ const factory WorkspaceMemberEvent.getInviteCode() = GetInviteCode;+ const factory WorkspaceMemberEvent.generateInviteLink() = GenerateInviteLink;const factory WorkspaceMemberEvent.updateInviteLink(String inviteLink) =UpdateInviteLink;}diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_page.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_page.dartindex 690c68151b..c297a87307 100644--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_page.dart+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/members/workspace_member_page.dart@@ -34,7 +34,8 @@ class WorkspaceMembersPage extends StatelessWidget {Widget build(BuildContext context) {return BlocProvider<WorkspaceMemberBloc>(create: (context) => WorkspaceMemberBloc(userProfile: userProfile)- ..add(const WorkspaceMemberEvent.initial()),+ ..add(const WorkspaceMemberEvent.initial())+ ..add(const WorkspaceMemberEvent.getInviteCode()),child: BlocConsumer<WorkspaceMemberBloc, WorkspaceMemberState>(listener: _showResultDialog,builder: (context, state) {diff --git a/frontend/resources/translations/en.json b/frontend/resources/translations/en.jsonindex b0c05c6f5b..bd9e6e26d3 100644--- a/frontend/resources/translations/en.json+++ b/frontend/resources/translations/en.json@@ -85,7 +85,27 @@"loginAs": "Login as","invalidVerificationCode": "Please enter a valid verification code","tooFrequentVerificationCodeRequest": "You have made too many requests. Please try again later.",- "invalidLoginCredentials": "Your password is incorrect, please try again"+ "invalidLoginCredentials": "Your password is incorrect, please try again",+ "resetPassword": "Reset password",+ "resetPasswordDescription": "Enter your email to reset your password",+ "continueToResetPassword": "Continue to reset password",+ "resetPasswordSuccess": "Password reset successfully",+ "resetPasswordFailed": "Failed to reset password",+ "resetPasswordLinkSent": "A password reset link has been sent to your email. Please check your inbox at",+ "resetPasswordLinkExpired": "The password reset link has expired. Please request a new link.",+ "resetPasswordLinkInvalid": "The password reset link is invalid. Please request a new link.",+ "enterNewPasswordFor": "Enter new password for ",+ "newPassword": "New password",+ "enterNewPassword": "Enter new password",+ "confirmPassword": "Confirm password",+ "confirmNewPassword": "Enter new password",+ "newPasswordCannotBeEmpty": "New password cannot be empty",+ "confirmPasswordCannotBeEmpty": "Confirm password cannot be empty",+ "passwordsDoNotMatch": "Passwords do not match",+ "verifying": "Verifying...",+ "continueWithPassword": "Continue with password",+ "youAreInLocalMode": "You're in local mode.",+ "loginToAppFlowyCloud": "Login to AppFlowy Cloud"},"workspace": {"chooseWorkspace": "Choose your workspace",@@ -2699,7 +2719,9 @@"newPasswordIsRequired": "New password is required","confirmPasswordIsRequired": "Confirm password is required","passwordsDoNotMatch": "Passwords do not match",- "newPasswordIsSameAsCurrent": "New password is same as current password"+ "newPasswordIsSameAsCurrent": "New password is same as current password",+ "currentPasswordIsIncorrect": "Current password is incorrect",+ "passwordShouldBeAtLeast6Characters": "Password should be at least 6 characters"},"toast": {"passwordUpdatedSuccessfully": "Password updated successfully",