mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-25 16:09:42 +01:00
fix login flow if user email is not verified
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
ToastEvent,
|
||||
} from '../../services/EventManager';
|
||||
import {clearMessage, setEmailVerifyMessage} from '../../services/Message';
|
||||
import PremiumService from '../../services/PremiumService';
|
||||
import {getElevation} from '../../utils';
|
||||
import {db} from '../../utils/DB';
|
||||
import {
|
||||
@@ -190,11 +191,18 @@ const LoginDialog = () => {
|
||||
if (!user) throw new Error('Email or passoword incorrect!');
|
||||
setStatus('Syncing Data');
|
||||
dispatch({type: Actions.USER, user: user});
|
||||
await db.sync();
|
||||
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
|
||||
db.sync()
|
||||
.catch((e) => {})
|
||||
.finally(async () => {
|
||||
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
|
||||
});
|
||||
dispatch({type: Actions.ALL});
|
||||
eSendEvent(refreshNotesPage);
|
||||
clearMessage(dispatch);
|
||||
if (!user.isEmailConfirmed) {
|
||||
setEmailVerifyMessage(dispatch);
|
||||
PremiumService.showVerifyEmailDialog();
|
||||
}
|
||||
close();
|
||||
ToastEvent.show(`Logged in as ${user.email}`, 'success', 'global');
|
||||
} catch (e) {
|
||||
@@ -495,7 +503,7 @@ const LoginDialog = () => {
|
||||
validationType={mode === MODES.signup ? 'password' : null}
|
||||
secureTextEntry
|
||||
placeholder="Password"
|
||||
errorMessage={mode === MODES.signup && "Password is invalid"}
|
||||
errorMessage={mode === MODES.signup && 'Password is invalid'}
|
||||
onSubmit={() => {
|
||||
if (
|
||||
mode === MODES.signup ||
|
||||
|
||||
@@ -58,21 +58,27 @@ async function checkBackupRequired(type) {
|
||||
lastBackupDate = parseInt(lastBackupDate);
|
||||
|
||||
if (type === 'daily') {
|
||||
console.log('backing up data daily!');
|
||||
now = new Date(now);
|
||||
lastBackupDate = new Date(lastBackupDate);
|
||||
|
||||
if (now.getUTCDate() > lastBackupDate.getUTCDate()) {
|
||||
console.log('backup is needed');
|
||||
return true;
|
||||
} else if (
|
||||
(now.getUTCDate() === lastBackupDate.getUTCDate() &&
|
||||
now.getUTCFullYear() > lastBackupDate.getUTCFullYear()) ||
|
||||
now.getUTCMonth() > lastBackupDate.getUTCMonth()
|
||||
) {
|
||||
console.log('backup is needed');
|
||||
return true;
|
||||
} else {
|
||||
console.log('backup is not needed');
|
||||
return false;
|
||||
}
|
||||
} else if (type === 'weekly') {
|
||||
if (lastBackupDate + MS_WEEK < now) {
|
||||
console.log('backup is needed');
|
||||
return true;
|
||||
} else {
|
||||
false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {CHECK_IDS} from 'notes-core/common';
|
||||
import {db} from '../utils/DB';
|
||||
import {eOpenPremiumDialog, eShowGetPremium} from '../utils/Events';
|
||||
import {eOpenPremiumDialog, eOpenProgressDialog, eShowGetPremium} from '../utils/Events';
|
||||
import {MMKV} from '../utils/mmkv';
|
||||
import {eSendEvent, ToastEvent} from './EventManager';
|
||||
|
||||
|
||||
@@ -10,10 +10,9 @@ export const db = new Database(
|
||||
Platform.OS === 'ios' ? EventSource : AndroidEventSource,
|
||||
);
|
||||
|
||||
//"https://api.notesnook.com"
|
||||
|
||||
db.host({
|
||||
API_HOST: 'https://192.168.10.5:5264',
|
||||
AUTH_HOST: 'https://192.168.10.5:8264',
|
||||
SSE_HOST: 'https://192.168.10.5:7264',
|
||||
API_HOST: 'https://api.notesnook.com',
|
||||
AUTH_HOST: 'https://auth.streetwriters.co',
|
||||
SSE_HOST: 'https://events.streetwriters.co',
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { createRef, useCallback, useEffect, useState } from 'react';
|
||||
import React, {createRef, useCallback, useEffect, useState} from 'react';
|
||||
import {
|
||||
Appearance,
|
||||
InteractionManager,
|
||||
@@ -6,54 +6,53 @@ import {
|
||||
Platform,
|
||||
ScrollView,
|
||||
TouchableOpacity,
|
||||
View
|
||||
View,
|
||||
} from 'react-native';
|
||||
import * as Keychain from 'react-native-keychain';
|
||||
import { enabled } from 'react-native-privacy-snapshot';
|
||||
import Menu, { MenuItem } from 'react-native-reanimated-material-menu';
|
||||
import {enabled} from 'react-native-privacy-snapshot';
|
||||
import Menu, {MenuItem} from 'react-native-reanimated-material-menu';
|
||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
import { Button } from '../../components/Button';
|
||||
import {Button} from '../../components/Button';
|
||||
import BaseDialog from '../../components/Dialog/base-dialog';
|
||||
import DialogButtons from '../../components/Dialog/dialog-buttons';
|
||||
import DialogContainer from '../../components/Dialog/dialog-container';
|
||||
import DialogHeader from '../../components/Dialog/dialog-header';
|
||||
import { PressableButton } from '../../components/PressableButton';
|
||||
import {PressableButton} from '../../components/PressableButton';
|
||||
import Seperator from '../../components/Seperator';
|
||||
import { ListHeaderComponent } from '../../components/SimpleList/ListHeaderComponent';
|
||||
import {ListHeaderComponent} from '../../components/SimpleList/ListHeaderComponent';
|
||||
import Heading from '../../components/Typography/Heading';
|
||||
import Paragraph from '../../components/Typography/Paragraph';
|
||||
import { useTracked } from '../../provider';
|
||||
import { Actions } from '../../provider/Actions';
|
||||
import {useTracked} from '../../provider';
|
||||
import {Actions} from '../../provider/Actions';
|
||||
import Backup from '../../services/Backup';
|
||||
import { DDS } from '../../services/DeviceDetection';
|
||||
import {DDS} from '../../services/DeviceDetection';
|
||||
import {
|
||||
eSendEvent,
|
||||
eSubscribeEvent,
|
||||
eUnSubscribeEvent,
|
||||
openVault,
|
||||
ToastEvent
|
||||
ToastEvent,
|
||||
} from '../../services/EventManager';
|
||||
import { setLoginMessage } from '../../services/Message';
|
||||
import {setLoginMessage} from '../../services/Message';
|
||||
import Navigation from '../../services/Navigation';
|
||||
import PremiumService from '../../services/PremiumService';
|
||||
import SettingsService from '../../services/SettingsService';
|
||||
import {
|
||||
AndroidModule,
|
||||
dWidth,
|
||||
|
||||
MenuItemsList,
|
||||
setSetting,
|
||||
SUBSCRIPTION_STATUS_STRINGS
|
||||
SUBSCRIPTION_STATUS_STRINGS,
|
||||
} from '../../utils';
|
||||
import {
|
||||
ACCENT,
|
||||
COLOR_SCHEME,
|
||||
COLOR_SCHEME_DARK,
|
||||
COLOR_SCHEME_LIGHT,
|
||||
setColorScheme
|
||||
setColorScheme,
|
||||
} from '../../utils/Colors';
|
||||
import { hexToRGBA, RGB_Linear_Shade } from '../../utils/ColorUtils';
|
||||
import { db } from '../../utils/DB';
|
||||
import {hexToRGBA, RGB_Linear_Shade} from '../../utils/ColorUtils';
|
||||
import {db} from '../../utils/DB';
|
||||
import {
|
||||
eCloseProgressDialog,
|
||||
eOpenLoginDialog,
|
||||
@@ -62,12 +61,12 @@ import {
|
||||
eOpenRecoveryKeyDialog,
|
||||
eOpenRestoreDialog,
|
||||
eScrollEvent,
|
||||
eUpdateSearchState
|
||||
eUpdateSearchState,
|
||||
} from '../../utils/Events';
|
||||
import { MMKV } from '../../utils/mmkv';
|
||||
import { pv, SIZE } from '../../utils/SizeUtils';
|
||||
import {MMKV} from '../../utils/mmkv';
|
||||
import {pv, SIZE} from '../../utils/SizeUtils';
|
||||
import Storage from '../../utils/storage';
|
||||
import { timeConverter } from '../../utils/TimeUtils';
|
||||
import {timeConverter} from '../../utils/TimeUtils';
|
||||
|
||||
const otherItems = [
|
||||
{
|
||||
@@ -993,18 +992,22 @@ const SettingsBackupAndRestore = () => {
|
||||
<TouchableOpacity
|
||||
activeOpacity={1}
|
||||
onPress={async () => {
|
||||
await PremiumService.verify(async () => {
|
||||
if (Platform.OS === 'android') {
|
||||
let granted = await Storage.requestPermission();
|
||||
if (!granted) {
|
||||
ToastEvent.show(
|
||||
'You must give storage access to enable auto backups.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (item.value === 'off') {
|
||||
await SettingsService.set('reminder', item.value);
|
||||
});
|
||||
} else {
|
||||
await PremiumService.verify(async () => {
|
||||
if (Platform.OS === 'android') {
|
||||
let granted = await Storage.requestPermission();
|
||||
if (!granted) {
|
||||
ToastEvent.show(
|
||||
'You must give storage access to enable auto backups.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
await SettingsService.set('reminder', item.value);
|
||||
});
|
||||
}
|
||||
}}
|
||||
key={item.value}
|
||||
style={{
|
||||
|
||||
Reference in New Issue
Block a user