Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix auth

ammarahm-ed32531685c7fe
diff --git a/apps/mobile/src/components/Auth/changepassword.js b/apps/mobile/src/components/Auth/changepassword.js
index 2a86304e6..952c617f9 100644
--- a/apps/mobile/src/components/Auth/changepassword.js
+++ b/apps/mobile/src/components/Auth/changepassword.js
@@ -1,6 +1,7 @@
import React, { useRef, useState } from 'react';
import { View } from 'react-native';
import { useTracked } from '../../provider';
+import { useUserStore } from '../../provider/stores';
import { eSendEvent, presentSheet, ToastEvent } from '../../services/EventManager';
import { db } from '../../utils/database';
import { eCloseProgressDialog } from '../../utils/Events';
@@ -20,8 +21,18 @@ export const ChangePassword = () => {
const [error, setError] = useState(false);
const [loading, setLoading] = useState(false);
+ const user = useUserStore(state => state.user);
const changePassword = async () => {
+ if (!user.isEmailConfirmed) {
+ ToastEvent.show({
+ heading: 'Email not confirmed',
+ message: 'Please confirm your email to change account password',
+ type: 'error',
+ context: 'local'
+ });
+ return;
+ }
if (error || !oldPassword.current || !password.current) {
ToastEvent.show({
heading: 'All fields required',
@@ -31,16 +42,19 @@ export const ChangePassword = () => {
});
return;
}
- eSendEvent(eCloseProgressDialog);
setLoading(true);
try {
+ await db.user.clearSessions();
await db.user.changePassword(oldPassword.current, password.current);
ToastEvent.show({
heading: `Account password updated`,
type: 'success',
- context: 'local'
+ context: 'global'
});
+ setLoading(false);
+ eSendEvent(eCloseProgressDialog);
} catch (e) {
+ setLoading(false);
ToastEvent.show({
heading: 'Failed to change password',
message: e.message,
@@ -92,7 +106,7 @@ export const ChangePassword = () => {
/>
<Notice
- text="Changing password is a non-undoable process. Please make sure you do not close the app while your password is changing and have good internet connection"
+ text="Changing password is a non-undoable process. You will be logged out from all your devices. Please make sure you do not close the app while your password is changing and have good internet connection."
type="alert"
/>
diff --git a/apps/mobile/src/components/Auth/forgotpassword.js b/apps/mobile/src/components/Auth/forgotpassword.js
index f1925588b..e154f8595 100644
--- a/apps/mobile/src/components/Auth/forgotpassword.js
+++ b/apps/mobile/src/components/Auth/forgotpassword.js
@@ -42,13 +42,15 @@ export const ForgotPassword = () => {
await MMKV.setItem('lastRecoveryEmailTime', JSON.stringify(Date.now()));
ToastEvent.show({
heading: `Check your email to reset password`,
- message: `Recovery email has been sent to ${email.toLowerCase()}`,
+ message: `Recovery email has been sent to ${email.current.toLowerCase()}`,
type: 'success',
context: 'local',
duration: 7000
});
setLoading(false);
+ setSent(true);
} catch (e) {
+ setLoading(false);
ToastEvent.show({
heading: 'Recovery email not sent',
message: e.message,
@@ -64,7 +66,9 @@ export const ForgotPassword = () => {
onBeforeShow={data => (email.current = data)}
onClose={() => {
setSent(false);
+ setLoading(false);
}}
+ keyboardShouldPersistTaps="always"
onOpen={() => {
emailInputRef.current?.setNativeProps({
text: email.current