From 5153b43bc61c8e0193c76f61d58c0700277dcbd3 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Fri, 13 Feb 2026 11:27:58 +0500 Subject: [PATCH] mobile: enable password change and forgot password --- .../app/components/auth/change-password.tsx | 10 +- .../app/components/auth/forgot-password.tsx | 153 ++++++++---------- apps/mobile/app/components/auth/login.tsx | 16 +- .../app/components/auth/session-expired.tsx | 2 +- apps/mobile/app/components/paywall/index.tsx | 1 + .../components/sheets/recovery-key/index.jsx | 2 +- .../app/screens/settings/settings-data.tsx | 13 +- apps/mobile/package-lock.json | 4 +- 8 files changed, 92 insertions(+), 109 deletions(-) diff --git a/apps/mobile/app/components/auth/change-password.tsx b/apps/mobile/app/components/auth/change-password.tsx index 1fc7dd816..a3ca00938 100644 --- a/apps/mobile/app/components/auth/change-password.tsx +++ b/apps/mobile/app/components/auth/change-password.tsx @@ -73,7 +73,15 @@ export const ChangePassword = () => { throw new Error(strings.backupFailed() + `: ${result.error}`); } - await db.user.changePassword(oldPassword.current, password.current); + const passwordChanged = await db.user.changePassword( + oldPassword.current, + password.current + ); + + if (!passwordChanged) { + throw new Error("Could not change user account password."); + } + ToastManager.show({ heading: strings.passwordChangedSuccessfully(), type: "success", diff --git a/apps/mobile/app/components/auth/forgot-password.tsx b/apps/mobile/app/components/auth/forgot-password.tsx index 14e62a7ea..67f82e16e 100644 --- a/apps/mobile/app/components/auth/forgot-password.tsx +++ b/apps/mobile/app/components/auth/forgot-password.tsx @@ -19,7 +19,6 @@ along with this program. If not, see . import React, { useRef, useState } from "react"; import { TextInput, View } from "react-native"; -import ActionSheet from "react-native-actions-sheet"; import { db } from "../../common/database"; import { DDS } from "../../services/device-detection"; import { ToastManager } from "../../services/event-manager"; @@ -35,9 +34,9 @@ import Paragraph from "../ui/typography/paragraph"; import { strings } from "@notesnook/intl"; import { DefaultAppStyles } from "../../utils/styles"; -export const ForgotPassword = () => { +export const ForgotPassword = ({ userEmail }: { userEmail: string }) => { const { colors } = useThemeColors("sheet"); - const email = useRef(undefined); + const email = useRef(userEmail); const emailInputRef = useRef(null); const [error, setError] = useState(false); const [loading, setLoading] = useState(false); @@ -87,94 +86,76 @@ export const ForgotPassword = () => { return ( <> - (email.current = data)} - onClose={() => { - setSent(false); - setLoading(false); - }} - onOpen={() => { - emailInputRef.current?.setNativeProps({ - text: email.current - }); - }} - indicatorStyle={{ - width: 100 - }} - gestureEnabled - id="forgotpassword_sheet" - > - {sent ? ( - + + {strings.recoveryEmailSent()} + - - {strings.recoveryEmailSent()} - - {strings.recoveryEmailSentDesc()} - - - ) : ( - + + ) : ( + + + + + { + email.current = value; }} - > - - + defaultValue={email.current} + onErrorCheck={(e) => setError(e)} + returnKeyLabel={strings.next()} + returnKeyType="next" + autoComplete="email" + validationType="email" + autoCorrect={false} + autoCapitalize="none" + errorMessage={strings.emailInvalid()} + placeholder={strings.email()} + onSubmit={() => {}} + /> - { - email.current = value; - }} - defaultValue={email.current} - onErrorCheck={(e) => setError(e)} - returnKeyLabel={strings.next()} - returnKeyType="next" - autoComplete="email" - validationType="email" - autoCorrect={false} - autoCapitalize="none" - errorMessage={strings.emailInvalid()} - placeholder={strings.email()} - onSubmit={() => {}} - /> - -