A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
mobile: enable password change and forgot password
Ammar Ahmed5153b43bc61c
diff --git a/apps/mobile/app/components/auth/change-password.tsx b/apps/mobile/app/components/auth/change-password.tsxindex 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.tsxindex 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 <http://www.gnu.org/licenses/>.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<string>(undefined);+ const email = useRef<string>(userEmail);const emailInputRef = useRef<TextInput>(null);const [error, setError] = useState(false);const [loading, setLoading] = useState(false);@@ -87,94 +86,76 @@ export const ForgotPassword = () => {return (<>- <ActionSheet- onBeforeShow={(data) => (email.current = data)}- onClose={() => {- setSent(false);- setLoading(false);- }}- onOpen={() => {- emailInputRef.current?.setNativeProps({- text: email.current- });- }}- indicatorStyle={{- width: 100- }}- gestureEnabled- id="forgotpassword_sheet"- >- {sent ? (- <View+ {sent ? (+ <View+ style={{+ padding: DefaultAppStyles.GAP,+ justifyContent: "center",+ alignItems: "center",+ paddingBottom: 50+ }}+ >+ <IconButtonstyle={{- padding: DefaultAppStyles.GAP,- justifyContent: "center",- alignItems: "center",- paddingBottom: 50+ width: null,+ height: null}}- >- <IconButton- style={{- width: null,- height: null- }}- color={colors.primary.accent}- name="email"- size={50}- />- <Heading>{strings.recoveryEmailSent()}</Heading>- <Paragraph- style={{- textAlign: "center"- }}- >- {strings.recoveryEmailSentDesc()}- </Paragraph>- </View>- ) : (- <View+ color={colors.primary.accent}+ name="email"+ size={50}+ />+ <Heading>{strings.recoveryEmailSent()}</Heading>+ <Paragraphstyle={{- borderRadius: DDS.isTab ? 5 : 0,- backgroundColor: colors.primary.background,- zIndex: 10,- width: "100%",- padding: DefaultAppStyles.GAP+ textAlign: "center"}}>- <DialogHeader title={strings.accountRecovery()} />- <Seperator />+ {strings.recoveryEmailSentDesc()}+ </Paragraph>+ </View>+ ) : (+ <View+ style={{+ borderRadius: DDS.isTab ? 5 : 0,+ backgroundColor: colors.primary.background,+ zIndex: 10,+ width: "100%",+ padding: DefaultAppStyles.GAP+ }}+ >+ <DialogHeader title={strings.accountRecovery()} />+ <Seperator />- <Input- fwdRef={emailInputRef}- onChangeText={(value) => {- 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={() => {}}- />+ <Input+ fwdRef={emailInputRef}+ onChangeText={(value) => {+ 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={() => {}}+ />- <Button- style={{- marginTop: DefaultAppStyles.GAP_VERTICAL,- width: "100%"- }}- loading={loading}- onPress={sendRecoveryEmail}- type="accent"- title={loading ? null : strings.next()}- />- </View>- )}- </ActionSheet>+ <Button+ style={{+ marginTop: DefaultAppStyles.GAP_VERTICAL,+ width: "100%"+ }}+ loading={loading}+ onPress={sendRecoveryEmail}+ type="accent"+ title={loading ? null : strings.next()}+ />+ </View>+ )}</>);};diff --git a/apps/mobile/app/components/auth/login.tsx b/apps/mobile/app/components/auth/login.tsxindex a9f869267..5fb5b72b8 100644--- a/apps/mobile/app/components/auth/login.tsx+++ b/apps/mobile/app/components/auth/login.tsx@@ -25,7 +25,11 @@ import { TouchableOpacity, View, useWindowDimensions } from "react-native";import { SheetManager } from "react-native-actions-sheet";import { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";import { DDS } from "../../services/device-detection";-import { eSendEvent, ToastManager } from "../../services/event-manager";+import {+ eSendEvent,+ presentSheet,+ ToastManager+} from "../../services/event-manager";import Navigation from "../../services/navigation";import PremiumService from "../../services/premium";import SettingsService from "../../services/settings";@@ -110,7 +114,6 @@ export const Login = ({return (<><AuthHeader />- <ForgotPassword /><Dialog context="two_factor_verify" /><KeyboardAwareScrollViewstyle={{@@ -257,13 +260,10 @@ export const Login = ({paddingHorizontal: 0}}onPress={() => {- ToastManager.show({- type: "info",- message:- "Password changing has been disabled temporarily to address some issues faced by users. It will be enabled again once the issues have resolved."+ if (loading || !email.current) return;+ presentSheet({+ component: <ForgotPassword userEmail={email.current} />});- // if (loading || !email.current) return;- // SheetManager.show("forgotpassword_sheet");}}textStyle={{textDecorationLine: "underline"diff --git a/apps/mobile/app/components/auth/session-expired.tsx b/apps/mobile/app/components/auth/session-expired.tsxindex f6df8a902..360f8153e 100644--- a/apps/mobile/app/components/auth/session-expired.tsx+++ b/apps/mobile/app/components/auth/session-expired.tsx@@ -97,7 +97,7 @@ export const SessionExpired = () => {if (db.tokenManager._isTokenExpired(res))throw new Error("token expired");- const key = await db.user.getEncryptionKey();+ const key = await db.user.getDataEncryptionKeys();if (!key) throw new Error("No encryption key found.");Sync.run("global", false, "full", async (complete) => {diff --git a/apps/mobile/app/components/paywall/index.tsx b/apps/mobile/app/components/paywall/index.tsxindex 8a7d7b624..c4bea39b2 100644--- a/apps/mobile/app/components/paywall/index.tsx+++ b/apps/mobile/app/components/paywall/index.tsx@@ -182,6 +182,7 @@ const PayWall = (props: NavigationProps<"PayWall">) => {><IconButtonname="close"+ color={colors.primary.icon}onPress={() => {Navigation.replace("FluidPanelsView", {});}}diff --git a/apps/mobile/app/components/sheets/recovery-key/index.jsx b/apps/mobile/app/components/sheets/recovery-key/index.jsxindex 45f5dd2b5..7b0825d0e 100644--- a/apps/mobile/app/components/sheets/recovery-key/index.jsx+++ b/apps/mobile/app/components/sheets/recovery-key/index.jsx@@ -169,7 +169,7 @@ class RecoveryKeySheet extends React.Component {};onOpen = async () => {- let k = await db.user.getEncryptionKey();+ let k = await db.user.getMasterKey();this.user = await db.user.getUser();if (k) {this.setState({diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsxindex 34a506918..bbf2e4d70 100644--- a/apps/mobile/app/screens/settings/settings-data.tsx+++ b/apps/mobile/app/screens/settings/settings-data.tsx@@ -331,17 +331,10 @@ export const settingsGroups: SettingSection[] = [{id: "change-password",name: strings.changePassword(),- // type: "screen",+ type: "screen",description: strings.changePasswordDesc(),- // component: "change-password",- icon: "form-textbox-password",- modifer: () => {- ToastManager.show({- type: "info",- message:- "Password changing has been disabled temporarily to address some issues faced by users. It will be enabled again once the issues have resolved."- });- }+ component: "change-password",+ icon: "form-textbox-password"},{id: "change-email",diff --git a/apps/mobile/package-lock.json b/apps/mobile/package-lock.jsonindex 9409d3e6a..d84a50ee0 100644--- a/apps/mobile/package-lock.json+++ b/apps/mobile/package-lock.json@@ -1,12 +1,12 @@{"name": "@notesnook/mobile",- "version": "3.3.13-beta.1",+ "version": "3.3.13","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "@notesnook/mobile",- "version": "3.3.13-beta.1",+ "version": "3.3.13","hasInstallScript": true,"license": "GPL-3.0-or-later","dependencies": {