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
change login/signup
ammarahm-ed117c1f1f42cd
diff --git a/apps/mobile/babel.config.js b/apps/mobile/babel.config.jsindex 3b3890bb6..b752818ef 100644--- a/apps/mobile/babel.config.js+++ b/apps/mobile/babel.config.js@@ -1,4 +1,7 @@module.exports = {presets: ['module:metro-react-native-babel-preset'],- plugins: ['transform-remove-console', '@babel/plugin-transform-named-capturing-groups-regex']+ plugins: [+ //'transform-remove-console',+ '@babel/plugin-transform-named-capturing-groups-regex'+ ]};diff --git a/apps/mobile/src/components/AppLoader/index.js b/apps/mobile/src/components/AppLoader/index.jsindex 6e0a6832a..28272053a 100644--- a/apps/mobile/src/components/AppLoader/index.js+++ b/apps/mobile/src/components/AppLoader/index.js@@ -100,7 +100,7 @@ const AppLoader = ({ onLoad }) => {(async () => {await sleep(500);if ((await MMKV.getItem('loginSessionHasExpired')) === 'expired') {- eSendEvent(eOpenLoginDialog, 4);+ eSendEvent('session_expired');return;}diff --git a/apps/mobile/src/components/Dialog/BaseDialog.js b/apps/mobile/src/components/Dialog/BaseDialog.jsindex c324b0b1a..d61c82589 100644--- a/apps/mobile/src/components/Dialog/BaseDialog.js+++ b/apps/mobile/src/components/Dialog/BaseDialog.js@@ -6,7 +6,8 @@ import {Platform,SafeAreaView,StyleSheet,- TouchableOpacity+ TouchableOpacity,+ View} from 'react-native';import { useSettingStore } from '../../provider/stores';import useIsFloatingKeyboard from '../../utils/use-is-floating-keyboard';@@ -26,7 +27,8 @@ const BaseDialog = ({background = null,animated = true,bounce = true,- closeOnTouch = true+ closeOnTouch = true,+ useSafeArea = true}) => {const floating = useIsFloatingKeyboard();@@ -36,6 +38,8 @@ const BaseDialog = ({};}, []);+ const Wrapper = useSafeArea ? SafeAreaView : View;+return (<Modalvisible={visible}@@ -62,7 +66,7 @@ const BaseDialog = ({onRequestClose && onRequestClose();}}>- <SafeAreaView+ <Wrapperstyle={{backgroundColor: background ? background : transparent ? 'transparent' : 'rgba(0,0,0,0.3)'}}@@ -87,7 +91,7 @@ const BaseDialog = ({{children}</BouncingView></KeyboardAvoidingView>- </SafeAreaView>+ </Wrapper></Modal>);};diff --git a/apps/mobile/src/components/DialogManager/index.js b/apps/mobile/src/components/DialogManager/index.jsindex f1fac2af7..db5a93af0 100644--- a/apps/mobile/src/components/DialogManager/index.js+++ b/apps/mobile/src/components/DialogManager/index.js@@ -12,6 +12,7 @@ import ExportDialog from '../ExportDialog';import GeneralSheet from '../GeneralSheet';import ImagePreview from '../ImagePreview';import LoginDialog from '../LoginDialog';+import { SessionExpired } from '../LoginDialog/session-expired';import MergeEditor from '../MergeEditor';import MoveNoteDialog from '../MoveNoteDialog';import PremiumDialog from '../Premium';@@ -75,6 +76,7 @@ export class DialogManager extends Component {<AttachmentDialog /><Expiring /><AnnouncementDialog />+ <SessionExpired /></>);}diff --git a/apps/mobile/src/components/LoginDialog/background.js b/apps/mobile/src/components/LoginDialog/background.jsnew file mode 100644index 000000000..699a0c492--- /dev/null+++ b/apps/mobile/src/components/LoginDialog/background.js@@ -0,0 +1,2 @@+export const SVG = color =>+ `<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="1920" height="1080" preserveAspectRatio="none" viewBox="0 0 1920 1080"><g mask="url("#SvgjsMask1032")" fill="none"><rect width="1920" height="1080" x="0" y="0" fill="rgba(255, 255, 255, 1)"></rect><path d="M684.78-215.3C516.78-49.87 619.54 659.12 349.29 666.13 79.03 673.14-116.04 204.76-321.7 180.13" stroke="${color}" stroke-width="2"></path><path d="M1337.71-20.29C1105.2 122.03 1140.53 887.64 809.58 933.71 478.63 979.78 545.52 798.71 281.45 798.71 17.39 798.71-110.41 932.65-246.68 933.71" stroke="${color}" stroke-width="2"></path><path d="M1631.89-52.3C1379.35-21.93 1283.05 511.66 808.42 545.28 333.79 578.9 209.15 894.14-15.05 901.68" stroke="${color}" stroke-width="2"></path><path d="M1523.21-71.7C1244.4-46.38 1056.2 532.95 581.02 533.49 105.84 534.03-109.4 182.98-361.17 177.09" stroke="${color}" stroke-width="2"></path><path d="M1333.35-39.1C1041.86 57 974.42 893.52 550.36 906.48 126.3 919.44-23.8 619.56-232.63 614.88" stroke="${color}" stroke-width="2"></path></g><defs><mask id="SvgjsMask1032"><rect width="1920" height="1080" fill="#ffffff"></rect></mask></defs></svg>`;diff --git a/apps/mobile/src/components/LoginDialog/changepassword.js b/apps/mobile/src/components/LoginDialog/changepassword.jsnew file mode 100644index 000000000..f849c7182--- /dev/null+++ b/apps/mobile/src/components/LoginDialog/changepassword.js@@ -0,0 +1,117 @@+import React, { useRef, useState } from 'react';+import { View } from 'react-native';+import { useTracked } from '../../provider';+import { eSendEvent, presentSheet, ToastEvent } from '../../services/EventManager';+import { db } from '../../utils/database';+import { eCloseProgressDialog } from '../../utils/Events';+import { Button } from '../Button';+import DialogHeader from '../Dialog/dialog-header';+import Input from '../Input';+import { Notice } from '../Notice';+import Seperator from '../Seperator';++export const ChangePassword = () => {+ const [state] = useTracked();+ const colors = state.colors;+ const passwordInputRef = useRef();+ const password = useRef();+ const oldPasswordInputRef = useRef();+ const oldPassword = useRef();++ const [error, setError] = useState(false);+ const [loading, setLoading] = useState(false);++ const changePassword = async () => {+ if (error || !oldPassword || !password) {+ ToastEvent.show({+ heading: 'All fields required',+ message: 'Fill all the fields and try again.',+ type: 'error',+ context: 'local'+ });+ return;+ }+ eSendEvent(eCloseProgressDialog);+ setLoading(true);+ try {+ await db.user.changePassword(oldPassword, password);+ ToastEvent.show({+ heading: `Account password updated`,+ type: 'success',+ context: 'local'+ });+ } catch (e) {+ ToastEvent.show({+ heading: 'Failed to change password',+ message: e.message,+ type: 'error',+ context: 'local'+ });+ }+ setLoading(false);+ };++ return (+ <View+ style={{+ width: '100%',+ padding: 12+ }}+ >+ <DialogHeader title="Change password" paragraph="Enter your old and new passwords" />+ <Seperator />++ <Input+ fwdRef={oldPasswordInputRef}+ onChangeText={value => {+ oldPassword.current = value;+ }}+ returnKeyLabel="Next"+ returnKeyType="next"+ secureTextEntry+ autoCompleteType="password"+ autoCapitalize="none"+ autoCorrect={false}+ placeholder="Old Password"+ />++ <Input+ fwdRef={passwordInputRef}+ onChangeText={value => {+ password.current = value;+ }}+ onErrorCheck={e => setError(e)}+ returnKeyLabel="Next"+ returnKeyType="next"+ secureTextEntry+ validationType="password"+ autoCompleteType="password"+ autoCapitalize="none"+ autoCorrect={false}+ placeholder="New password"+ />++ <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"+ type="alert"+ />++ <Button+ style={{+ marginTop: 10,+ width: '100%'+ }}+ loading={loading}+ onPress={changePassword}+ type="accent"+ title={loading ? null : 'I understand, change my password'}+ />+ </View>+ );+};++ChangePassword.present = () => {+ presentSheet({+ component: <ChangePassword />+ });+};diff --git a/apps/mobile/src/components/LoginDialog/forgotpassword.js b/apps/mobile/src/components/LoginDialog/forgotpassword.jsnew file mode 100644index 000000000..d34fba9a7--- /dev/null+++ b/apps/mobile/src/components/LoginDialog/forgotpassword.js@@ -0,0 +1,152 @@+import React, { useRef, useState } from 'react';+import { View } from 'react-native';+import ActionSheet from 'react-native-actions-sheet';+import { useTracked } from '../../provider';+import { DDS } from '../../services/DeviceDetection';+import { ToastEvent } from '../../services/EventManager';+import { db } from '../../utils/database';+import { MMKV } from '../../utils/mmkv';+import { ActionIcon } from '../ActionIcon';+import { Button } from '../Button';+import DialogHeader from '../Dialog/dialog-header';+import Input from '../Input';+import Seperator from '../Seperator';+import Heading from '../Typography/Heading';+import Paragraph from '../Typography/Paragraph';++export const ForgotPassword = () => {+ const [state] = useTracked();+ const colors = state.colors;+ const email = useRef();+ const emailInputRef = useRef();+ const [error, setError] = useState(false);+ const [loading, setLoading] = useState(false);+ const [sent, setSent] = useState(false);++ const sendRecoveryEmail = async () => {+ if (!email || error) {+ ToastEvent.show({+ heading: 'Account email is required.',+ type: 'error',+ context: 'local'+ });+ return;+ }+ setLoading(true);+ try {+ let lastRecoveryEmailTime = await MMKV.getItem('lastRecoveryEmailTime');+ if (lastRecoveryEmailTime && Date.now() - JSON.parse(lastRecoveryEmailTime) < 60000 * 3) {+ throw new Error('Please wait before requesting another email');+ }+ await db.user.recoverAccount(email.toLowerCase());+ 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()}`,+ type: 'success',+ context: 'local',+ duration: 7000+ });+ setLoading(false);+ } catch (e) {+ ToastEvent.show({+ heading: 'Recovery email not sent',+ message: e.message,+ type: 'error',+ context: 'local'+ });+ }+ };++ return (+ <>+ <ActionSheet+ onBeforeShow={data => (email.current = data)}+ onClose={() => {+ setSent(false);+ }}+ onOpen={() => {+ emailInputRef.current?.setNativeProps({+ text: email.current+ });+ }}+ gestureEnabled+ id="forgotpassword_sheet"+ >+ {sent ? (+ <View+ style={{+ padding: 12,+ justifyContent: 'center',+ alignItems: 'center',+ paddingBottom: 50+ }}+ >+ <ActionIcon+ customStyle={{+ width: null,+ height: null+ }}+ color={colors.accent}+ name="email"+ size={50}+ />+ <Heading>Recovery email sent!</Heading>+ <Paragraph+ style={{+ textAlign: 'center'+ }}+ >+ Please follow the link in the email to recover your account.+ </Paragraph>+ </View>+ ) : (+ <View+ style={{+ borderRadius: DDS.isTab ? 5 : 0,+ backgroundColor: colors.bg,+ zIndex: 10,+ width: '100%',+ padding: 12+ }}+ >+ <DialogHeader+ title="Account recovery"+ paragraph="We will send you an email with steps on how to reset your password."+ />+ <Seperator />++ <Input+ fwdRef={emailInputRef}+ onChangeText={value => {+ email.current = value;+ }}+ defaultValue={email.current}+ onErrorCheck={e => setError(e)}+ returnKeyLabel="Next"+ returnKeyType="next"+ autoCompleteType="email"+ validationType="email"+ autoCorrect={false}+ autoCapitalize="none"+ errorMessage="Email is invalid"+ placeholder="Email"+ onSubmit={() => {}}+ />++ <Button+ style={{+ marginTop: 10,+ width: '100%'+ }}+ loading={loading}+ onPress={sendRecoveryEmail}+ type="accent"+ title={loading ? null : 'Next'}+ />+ </View>+ )}+ </ActionSheet>+ </>+ );+};diff --git a/apps/mobile/src/components/LoginDialog/index.js b/apps/mobile/src/components/LoginDialog/index.jsindex 03a363d39..af9057550 100644--- a/apps/mobile/src/components/LoginDialog/index.js+++ b/apps/mobile/src/components/LoginDialog/index.js@@ -1,805 +1,66 @@import React, { useEffect, useRef, useState } from 'react';-import { ScrollView, Text, TouchableOpacity, View } from 'react-native';-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';-import { Button } from '../../components/Button';-import Seperator from '../../components/Seperator';import { useTracked } from '../../provider/index';-import { useUserStore } from '../../provider/stores';-import BiometricService from '../../services/BiometricService';-import { DDS } from '../../services/DeviceDetection';-import {- eSendEvent,- eSubscribeEvent,- eUnSubscribeEvent,- presentSheet,- ToastEvent-} from '../../services/EventManager';-import { clearMessage, setEmailVerifyMessage } from '../../services/Message';-import PremiumService from '../../services/PremiumService';-import Sync from '../../services/Sync';-import { hexToRGBA } from '../../utils/ColorUtils';-import { db } from '../../utils/database';-import { eOpenLoginDialog, eOpenResultDialog } from '../../utils/Events';-import { openLinkInBrowser } from '../../utils/functions';-import { MMKV } from '../../utils/mmkv';-import { SIZE } from '../../utils/SizeUtils';-import Storage from '../../utils/storage';+import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';+import { eCloseLoginDialog, eOpenLoginDialog } from '../../utils/Events';import { sleep } from '../../utils/TimeUtils';-import SheetWrapper from '../Sheet';import BaseDialog from '../Dialog/base-dialog';-import DialogButtons from '../Dialog/dialog-buttons';-import DialogContainer from '../Dialog/dialog-container';-import DialogHeader from '../Dialog/dialog-header';-import Input from '../Input';-import { Header } from '../SimpleList/header';-import Paragraph from '../Typography/Paragraph';-import { ActionIcon } from '../ActionIcon';-import umami from '../../utils/umami';+import { Toast } from '../Toast';+import { Login } from './login';+import { Signup } from './signup';const MODES = {login: 0,signup: 1,- forgotPassword: 2,- changePassword: 3,- sessionExpired: 4+ welcomeSignup: 2};-let email = '';-let password = '';-let confirmPassword;-let oldPassword;--function getEmail() {- if (!email) return null;- return email.replace(/(.{2})(.*)(?=@)/, function (gp1, gp2, gp3) {- for (let i = 0; i < gp3.length; i++) {- gp2 += '*';- }- return gp2;- });-}const LoginDialog = () => {- const [state, dispatch] = useTracked();+ const [state] = useTracked();const colors = state.colors;-- const setUser = useUserStore(state => state.setUser);- const setLastSynced = useUserStore(state => state.setLastSynced);-const [visible, setVisible] = useState(false);- const [status, setStatus] = useState(null);- const [loading, setLoading] = useState(false);- const [userConsent, setUserConsent] = useState(true);const [mode, setMode] = useState(MODES.login);- const [error, setError] = useState(false);- const [focused, setFocused] = useState(false);- const [confirm, setConfirm] = useState(false);- const scrollViewRef = useRef();const actionSheetRef = useRef();- const _email = useRef();- const _pass = useRef();- const _oPass = useRef();- const _passConfirm = useRef();-- const MODE_DATA = [- {- headerButton: 'Login',- headerButtonFunc: () => {- setMode(MODES.signup);- },- button: 'Login',- buttonFunc: () => loginUser(),- headerParagraph: 'Create a new account',- showForgotButton: true,- loading: 'Please wait while we log in and sync your data.',- showLoader: true,- buttonAlt: 'Sign Up',- buttonAltFunc: () => {- setMode(MODES.signup);- }- },- {- headerButton: 'Sign Up',- headerButtonFunc: () => {- _email.current?.blur();- setMode(MODES.login);- onChangeFocus();- },- button: 'Create Account',- buttonFunc: () => signupUser(),- headerParagraph: 'Login to your account',- showForgotButton: false,- loading: 'Please wait while we set up your account.',- showLoader: true,- buttonAlt: 'Login',- buttonAltFunc: () => {- _email.current?.blur();- setMode(MODES.login);- onChangeFocus();- }- },- {- headerButton: 'Forgot Password',- headerButtonFunc: () => {- _email.current?.blur();- setMode(MODES.login);- onChangeFocus();- },- button: 'Send Recovery Email',- buttonFunc: () => sendEmail(),- headerParagraph: 'Login to your account',- showForgotButton: false,- loading:- 'Please follow the link in the email to set up your new password. If you are unable to find our email, check your spam folder.',- showLoader: false,- buttonAlt: 'Go back to Login',- buttonAltFunc: () => {- setMode(MODES.login);- }- },- {- headerButton: 'Change Password',- headerButtonFunc: () => {- setMode(MODES.signup);- },- button: 'Change Password',- buttonFunc: () => changePassword(),- headerParagraph: 'login to your account',- showForgotButton: false,- loading: 'Please wait while we change your password and encrypt your data.',- showLoader: true,- buttonAlt: null- },- {- headerButton: 'Session expired',- headerButtonFunc: () => {},- button: 'Login',- buttonFunc: () => loginUser(),- headerParagraph: '',- showForgotButton: true,- loading: 'Please wait while we log in and sync your data.',- showLoader: true,- buttonAlt: 'Logout',- buttonAltFunc: () => {- setConfirm(true);- }- }- ];-- const current = MODE_DATA[mode];useEffect(() => {eSubscribeEvent(eOpenLoginDialog, open);+ eSubscribeEvent(eCloseLoginDialog, close);return () => {eUnSubscribeEvent(eOpenLoginDialog, open);+ eUnSubscribeEvent(eCloseLoginDialog, close);};}, []);async function open(mode) {setMode(mode ? mode : MODES.login);- if (mode === MODES.sessionExpired) {- try {- console.log('REQUESTING NEW TOKEN');- let res = await db.user.tokenManager.getToken();- if (!res) throw new Error('no token found');- if (db.user.tokenManager._isTokenExpired(res)) throw new Error('token expired');- if (!(await Sync.run())) throw new Error('e');- await MMKV.removeItem('loginSessionHasExpired');- return;- } catch (e) {- console.log(e);- let user = await db.user.getUser();- if (!user) return;- email = user.email;- }- }- setStatus(null);setVisible(true);await sleep(10);actionSheetRef.current?.show();}const close = () => {- if (loading) return;actionSheetRef.current?.hide();- confirmPassword = null;- oldPassword = null;- email = null;- password = null;- setError(false);- setLoading(false);- setStatus(null);setMode(MODES.login);setVisible(false);};- const loginUser = async () => {- if (!password || !email || error) {- ToastEvent.show({- heading: 'Email or password is invalid',- type: 'error',- context: 'local'- });- return;- }- setLoading(true);- _email.current?.blur();- _pass.current?.blur();- setStatus('Logging in');- let user;- try {- await db.user.login(email.toLowerCase(), password);- user = await db.user.getUser();- if (!user) throw new Error('Email or password incorrect!');- setStatus('Syncing Your Data');- PremiumService.setPremiumStatus();- setUser(user);- clearMessage();- ToastEvent.show({- heading: 'Login successful',- message: `Logged in as ${user.email}`,- type: 'success',- context: 'local'- });- close();- await MMKV.removeItem('loginSessionHasExpired');- eSendEvent('userLoggedIn', true);- console.log('PRESENTING SHEET');- await sleep(500);- presentSheet({- title: 'Syncing your data',- paragraph: 'Please wait while we sync all your data.',- progress: true- });- } catch (e) {- setLoading(false);- setStatus(null);- ToastEvent.show({- heading: user ? 'Failed to sync' : 'Login failed',- message: e.message,- type: 'error',- context: 'local'- });- }- };-- const validateInfo = () => {- if (!password || !email || !confirmPassword) {- ToastEvent.show({- heading: 'All fields required',- message: 'Fill all the fields and try again',- type: 'error',- context: 'local'- });-- return false;- }-- if (error) {- ToastEvent.show({- heading: 'Invalid signup information',- message: 'Some or all information provided is invalid. Resolve all errors and try again.',- type: 'error',- context: 'local'- });- return false;- }-- if (!userConsent) {- ToastEvent.show({- heading: 'Cannot signup',- message: 'You must agree to our terms of service and privacy policy.',- type: 'error',- context: 'local',- actionText: 'I Agree',- duration: 5000,- func: () => {- setUserConsent(true);- signupUser();- ToastEvent.hide();- }- });- return false;- }-- return true;- };-- const signupUser = async () => {- if (!validateInfo()) return;- setLoading(true);- setStatus('Creating Account');- try {- await db.user.signup(email.toLowerCase(), password);- let user = await db.user.getUser();- setStatus('Setting Crenditials');- setUser(user);- setLastSynced(await db.lastSynced());- clearMessage();- setEmailVerifyMessage();- close();- umami.pageView('/account-created', '/welcome/signup');- await sleep(300);- eSendEvent(eOpenResultDialog);- } catch (e) {- setStatus(null);- setLoading(false);- ToastEvent.show({- heading: 'Signup failed',- message: e.message,- type: 'error',- context: 'local'- });- }- };-- const sendEmail = async nostatus => {- if (!email || error) {- ToastEvent.show({- heading: 'Account email is required.',- type: 'error',- context: 'local'- });- return;- }- try {- let lastRecoveryEmailTime = await MMKV.getItem('lastRecoveryEmailTime');- if (lastRecoveryEmailTime && Date.now() - JSON.parse(lastRecoveryEmailTime) < 60000 * 3) {- throw new Error('Please wait before requesting another email');- }- !nostatus && setStatus('Password Recovery Email Sent!');- await db.user.recoverAccount(email.toLowerCase());- 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()}`,- type: 'success',- context: 'local',- duration: 7000- });- } catch (e) {- setStatus(null);- ToastEvent.show({- heading: 'Recovery email not sent',- message: e.message,- type: 'error',- context: 'local'- });- }- };-- const changePassword = async () => {- if (error || !oldPassword || !password) {- ToastEvent.show({- heading: 'All fields required',- message: 'Fill all the fields and try again.',- type: 'error',- context: 'local'- });- return;- }- setLoading(true);- setStatus('Setting new Password');- try {- await db.user.changePassword(oldPassword, password);- ToastEvent.show({- heading: `Account password updated`,- type: 'success',- context: 'local'- });- } catch (e) {- setStatus(null);- ToastEvent.show({- heading: 'Failed to change password',- message: e.message,- type: 'error',- context: 'local'- });- }- setStatus(null);- setLoading(false);- };-- const onChangeFocus = () => {- setFocused(!focused);- setTimeout(() => {- _email.current?.focus();- }, 50);- };-return !visible ? null : (- <SheetWrapper- fwdRef={actionSheetRef}- animation={DDS.isTab ? 'fade' : 'slide'}+ <BaseDialog+ overlayOpacity={0}statusBarTranslucent={false}- gestureEnabled={MODES.sessionExpired !== mode}- closeOnTouchBackdrop={MODES.sessionExpired !== mode}onRequestClose={MODES.sessionExpired !== mode && close}- keyboardMode="position"visible={true}onClose={close}- onOpen={() => {- setTimeout(() => {- if (MODES.sessionExpired === mode) {- _pass.current?.focus();- setFocused(true);- return;- }- _email.current?.focus();- setFocused(true);- }, 500);- }}- background={!DDS.isTab ? colors.bg : null}+ background={colors.bg}transparent={true}>- {confirm && (- <BaseDialog- onRequestClose={() => {- setConfirm(false);- }}- visible- >- <DialogContainer>- <DialogHeader- title="Logout"- paragraph="All user data on this device will be cleared including any unsynced changes. Do you want to proceed?"- paragraphColor="red"- padding={12}- />- <Seperator />- <DialogButtons- negativeTitle="Cancel"- onPressNegative={() => {- setConfirm(false);- }}- positiveType="error"- positiveTitle="Logout"- onPressPositive={async () => {- try {- await db.user.logout();- await BiometricService.resetCredentials();- await Storage.write('introCompleted', 'true');- setConfirm(false);- close();- } catch (e) {- ToastEvent.show({- heading: e.message,- type: 'error',- context: 'local'- });- }- }}- />- </DialogContainer>- </BaseDialog>- )}-- {status ? (- <BaseDialog- visible={true}- transparent={current.showLoader}- animation="fade"- onRequestClose={() => {- if (!current.showLoader) {- setStatus(null);- }- }}- />- ) : null}-- <ScrollView- ref={scrollViewRef}- keyboardShouldPersistTaps="always"- keyboardDismissMode="none"- nestedScrollEnabled={mode !== MODES.sessionExpired}- onMomentumScrollEnd={() => {- actionSheetRef.current.handleChildScrollEnd();- }}- bounces={false}- overScrollMode="never"- scrollToOverflowEnabled="false"- style={{- borderRadius: DDS.isTab ? 5 : 0,- backgroundColor: colors.bg,- zIndex: 10,- minHeight: DDS.isTab ? '50%' : '85%'- }}- >- <Header- color="transparent"- type="login"- height={150}- noAnnouncement={true}- shouldShow- title={current.headerButton}- messageCard={false}- />- {mode === MODES.sessionExpired && (- <View- style={{- width: '100%',- paddingHorizontal: 12,- paddingVertical: 12,- marginTop: 10,- flexDirection: 'row',- alignItems: 'center',- backgroundColor: hexToRGBA(colors.red, 0.2)- }}- >- <Icon- size={20}- style={{ marginRight: 10 }}- name="information"- color={colors.errorText}- />- <Paragraph style={{ maxWidth: '90%' }} color={colors.errorText}>- Please log in to your account to access your notes on this device and sync them.- </Paragraph>- </View>- )}-- {mode === MODES.signup && (- <View- style={{- width: '100%',- backgroundColor: colors.shade,- paddingHorizontal: 12,- paddingVertical: 12,- marginTop: 10,- flexDirection: 'row',- alignItems: 'center'- }}- >- <Icon size={20} style={{ marginRight: 10 }} name="information" color={colors.accent} />- <Paragraph size={SIZE.xs + 1} style={{ maxWidth: '90%' }} color={colors.accent}>- Your 14 day free trial of Notesnook Pro will activate when you sign up.{' '}- <Paragraph size={SIZE.xs + 1} color={colors.accent} style={{ fontWeight: 'bold' }}>- No credit card is required.- </Paragraph>- </Paragraph>- </View>- )}-- <View- style={{- paddingHorizontal: 12,- paddingTop: 12,- width: focused ? '100%' : '99.9%'- }}- >- {mode === MODES.changePassword ? null : (- <Input- fwdRef={_email}- onChangeText={value => {- email = value;- }}- onErrorCheck={r => {- setError(r);- }}- loading={MODES.sessionExpired === mode}- defaultValue={MODES.sessionExpired === mode ? getEmail() : null}- onFocusInput={onChangeFocus}- returnKeyLabel="Next"- returnKeyType="next"- autoCompleteType="email"- validationType="email"- autoCorrect={false}- autoCapitalize="none"- errorMessage="Email is invalid"- placeholder="Email"- onSubmit={() => {- if (mode === MODES.signup || mode === MODES.login) {- _pass.current?.focus();- }- }}- />- )}-- {mode !== MODES.changePassword ? null : (- <Input- fwdRef={_oPass}- onChangeText={value => {- oldPassword = value;- }}- onErrorCheck={r => {- setError(r);- }}- returnKeyLabel="Next"- returnKeyType="next"- secureTextEntry- autoCompleteType="password"- autoCapitalize="none"- autoCorrect={false}- placeholder="Current password"- onSubmit={() => {- if (mode === MODES.signup) {- _pass.current?.focus();- }- }}- />- )}+ <Toast context="local" />- {mode === MODES.forgotPassword ? null : (- <>- <Input- fwdRef={_pass}- onChangeText={value => {- password = value;- }}- onErrorCheck={r => {- setError(r);- }}- marginBottom={0}- validationType={mode === MODES.signup ? 'password' : null}- secureTextEntry- autoCompleteType="password"- autoCapitalize="none"- autoCorrect={false}- placeholder="Password"- returnKeyLabel={mode === MODES.signup ? 'Next' : 'Login'}- returnKeyType={mode === MODES.signup ? 'next' : 'done'}- errorMessage={mode === MODES.signup && 'Password is invalid'}- onSubmit={() => {- if (mode === MODES.signup || mode === MODES.changePassword) {- _passConfirm.current?.focus();- } else {- current.buttonFunc();- }- }}- />- </>- )}-- {mode === MODES.login || mode === MODES.sessionExpired ? (- <Button- title="Forgot password?"- style={{- alignSelf: 'flex-end',- height: 30- }}- onPress={() => {- if (MODES.sessionExpired === mode) {- sendEmail(true);- return;- }- setMode(MODES.forgotPassword);- }}- />- ) : null}-- <Seperator />- {mode !== MODES.signup && mode !== MODES.changePassword ? null : (- <>- <Input- fwdRef={_passConfirm}- onChangeText={value => {- confirmPassword = value;- }}- onErrorCheck={r => {- setError(r);- }}- loading={loading}- validationType="confirmPassword"- autoCapitalize="none"- returnKeyLabel="Done"- returnKeyType="done"- autoCorrect={false}- customValidator={() => password}- secureTextEntry- placeholder="Confirm password"- errorMessage="Passwords do not match"- onSubmit={() => {- current.buttonFunc();- }}- />- </>- )}-- {mode !== MODES.signup ? null : (- <>- <TouchableOpacity- disabled={loading}- activeOpacity={0.7}- style={{- flexDirection: 'row',- width: '100%',- alignItems: 'center'- }}- >- <Paragraph- size={11}- style={{- maxWidth: '90%'- }}- >- By signing up you agree to our{' '}- <Paragraph- size={11}- onPress={() => {- openLinkInBrowser('https://notesnook.com/tos', colors)- .catch(e => {})- .then(r => {});- }}- color={colors.accent}- >- terms of service{' '}- </Paragraph>- and{' '}- <Paragraph- size={11}- onPress={() => {- openLinkInBrowser('https://notesnook.com/privacy', colors)- .catch(e => {})- .then(r => {});- }}- color={colors.accent}- >- privacy policy.- </Paragraph>- </Paragraph>- </TouchableOpacity>- </>- )}-- {mode !== MODES.signup ? null : <Seperator />}-- <Button- title={loading ? '' : current.button}- onPress={current.buttonFunc}- width="100%"- type="accent"- fontSize={SIZE.md}- loading={loading}- height={50}- />-- {current.buttonAlt ? (- <Button- title={current.buttonAlt}- onPress={current.buttonAltFunc}- width="100%"- type={MODES.sessionExpired === mode ? 'error' : 'shade'}- fontSize={SIZE.md}- style={{- marginTop: 10- }}- height={50}- />- ) : null}-- {loading && mode === MODES.changePassword ? (- <View- style={{- backgroundColor: colors.warningBg,- width: '100%',- borderRadius: 10,- marginTop: 10,- padding: 12,- flexDirection: 'row',- alignItems: 'center',- flexShrink: 1- }}- >- <ActionIcon name="alert" color={colors.warningText} />- <Paragraph- style={{- flexShrink: 1,- marginLeft: 5- }}- color={colors.warningText}- >- Do not close the app or move it to background while we change your password.- </Paragraph>- </View>- ) : null}- </View>-- <View- style={{- height: 100- }}- />- </ScrollView>- </SheetWrapper>+ {mode === MODES.signup || mode === MODES.welcomeSignup ? (+ <Signup changeMode={mode => setMode(mode)} welcome={mode === MODES.welcomeSignup} />+ ) : (+ <Login changeMode={mode => setMode(mode)} />+ )}+ </BaseDialog>);};diff --git a/apps/mobile/src/components/LoginDialog/login.js b/apps/mobile/src/components/LoginDialog/login.jsnew file mode 100644index 000000000..5d60923fd--- /dev/null+++ b/apps/mobile/src/components/LoginDialog/login.js@@ -0,0 +1,252 @@+import React, { useEffect, useRef, useState } from 'react';+import { View } from 'react-native';+import { eCloseLoginDialog } from '../../utils/Events';+import { useTracked } from '../../provider';+import { useUserStore } from '../../provider/stores';+import { DDS } from '../../services/DeviceDetection';+import { eSendEvent, presentSheet, ToastEvent } from '../../services/EventManager';+import { clearMessage } from '../../services/Message';+import PremiumService from '../../services/PremiumService';+import { db } from '../../utils/database';+import { MMKV } from '../../utils/mmkv';+import { SIZE } from '../../utils/SizeUtils';+import { sleep } from '../../utils/TimeUtils';+import { ActionIcon } from '../ActionIcon';+import { Button } from '../Button';+import BaseDialog from '../Dialog/base-dialog';+import Input from '../Input';+import { SvgToPngView } from '../ListPlaceholders';+import Heading from '../Typography/Heading';+import Paragraph from '../Typography/Paragraph';+import { SVG } from './background';+import { ForgotPassword } from './forgot-password';+import { SheetManager } from 'react-native-actions-sheet';++export const Login = ({ changeMode }) => {+ const [state] = useTracked();+ const colors = state.colors;+ const email = useRef();+ const emailInputRef = useRef();+ const passwordInputRef = useRef();+ const password = useRef();++ const [focused, setFocused] = useState(false);++ const [error, setError] = useState(false);+ const [loading, setLoading] = useState(false);++ const setUser = useUserStore(state => state.setUser);++ const validateInfo = () => {+ if (!password.current || !email.current) {+ ToastEvent.show({+ heading: 'All fields required',+ message: 'Fill all the fields and try again',+ type: 'error',+ context: 'local'+ });++ return false;+ }++ return true;+ };++ useEffect(() => {+ async () => {+ await sleep(500);+ emailInputRef.current?.focus();+ setFocused(true);+ };+ }, []);++ const login = async () => {+ if (!validateInfo() || error) return;+ setLoading(true);+ let user;+ try {+ await db.user.login(email.toLowerCase(), password);+ user = await db.user.getUser();+ if (!user) throw new Error('Email or password incorrect!');+ PremiumService.setPremiumStatus();+ setUser(user);+ clearMessage();+ ToastEvent.show({+ heading: 'Login successful',+ message: `Logged in as ${user.email}`,+ type: 'success',+ context: 'global'+ });+ eSendEvent(eCloseLoginDialog);+ await MMKV.removeItem('loginSessionHasExpired');+ eSendEvent('userLoggedIn', true);+ await sleep(500);+ presentSheet({+ title: 'Syncing your data',+ paragraph: 'Please wait while we sync all your data.',+ progress: true+ });+ } catch (e) {+ setLoading(false);+ ToastEvent.show({+ heading: user ? 'Failed to sync' : 'Login failed',+ message: e.message,+ type: 'error',+ context: 'local'+ });+ }+ };++ return (+ <>+ <ActionIcon+ name="arrow-left"+ onPress={() => {+ eSendEvent(eCloseLoginDialog);+ }}+ color={colors.pri}+ customStyle={{+ position: 'absolute',+ zIndex: 999,+ left: 12,+ top: 12+ }}+ />++ <ForgotPassword />++ {loading ? <BaseDialog transparent={true} visible={true} animation="fade" /> : null}+ <View+ style={{+ borderRadius: DDS.isTab ? 5 : 0,+ backgroundColor: colors.bg,+ zIndex: 10,+ width: '100%',+ minHeight: '100%'+ }}+ >+ <View+ style={{+ height: 250,+ overflow: 'hidden'+ }}+ >+ <SvgToPngView src={SVG(colors.night ? 'white' : 'black')} height={700} />+ </View>++ <View+ style={{+ width: '100%',+ justifyContent: 'center',+ alignSelf: 'center',+ paddingHorizontal: 12,+ marginBottom: 30,+ marginTop: 15+ }}+ >+ <Heading+ style={{+ textAlign: 'center'+ }}+ size={30}+ color={colors.heading}+ >+ Welcome back!+ </Heading>+ <Paragraph+ style={{+ textDecorationLine: 'underline',+ textAlign: 'center',+ marginTop: 5+ }}+ onPress={() => {+ changeMode(1);+ }}+ size={SIZE.md}+ >+ Don't have an account? Sign up+ </Paragraph>+ </View>+ <View+ style={{+ width: focused ? '100%' : '99.9%',+ padding: 12,+ backgroundColor: colors.bg,+ flexGrow: 1+ }}+ >+ <Input+ fwdRef={emailInputRef}+ onChangeText={value => {+ email.current = value;+ }}+ onErrorCheck={e => setError(e)}+ returnKeyLabel="Next"+ returnKeyType="next"+ autoCompleteType="email"+ validationType="email"+ autoCorrect={false}+ autoCapitalize="none"+ errorMessage="Email is invalid"+ placeholder="Email"+ onSubmit={() => {}}+ />++ <Input+ fwdRef={passwordInputRef}+ onChangeText={value => {+ password.current = value;+ }}+ onErrorCheck={e => setError(e)}+ returnKeyLabel="Done"+ returnKeyType="done"+ secureTextEntry+ autoCompleteType="password"+ autoCapitalize="none"+ validationType="password"+ autoCorrect={false}+ placeholder="Password"+ marginBottom={0}+ />+ <Button+ title="Forgot your password?"+ style={{+ alignSelf: 'flex-end',+ height: 30,+ paddingHorizontal: 0+ }}+ onPress={() => {+ SheetManager.show('forgotpassword_sheet', email.current);+ }}+ textStyle={{+ textDecorationLine: 'underline'+ }}+ fontSize={SIZE.xs}+ type="gray"+ />++ <View+ style={{+ // position: 'absolute',+ marginTop: 50,+ alignSelf: 'center'+ }}+ >+ <Button+ style={{+ marginTop: 10,+ width: 250,+ borderRadius: 100+ }}+ loading={loading}+ onPress={login}+ // width="100%"+ type="accent"+ title={loading ? null : 'Log in to your account'}+ />+ </View>+ </View>+ </View>+ </>+ );+};diff --git a/apps/mobile/src/components/LoginDialog/sessionexpired.js b/apps/mobile/src/components/LoginDialog/sessionexpired.jsnew file mode 100644index 000000000..e57828343--- /dev/null+++ b/apps/mobile/src/components/LoginDialog/sessionexpired.js@@ -0,0 +1,235 @@+import React, { useEffect, useRef, useState } from 'react';+import { Modal, View } from 'react-native';+import Sync from '../../services/Sync';+import { MMKV } from '../../utils/mmkv';+import { useTracked } from '../../provider';+import BiometricService from '../../services/BiometricService';+import {+ eSendEvent,+ eSubscribeEvent,+ eUnSubscribeEvent,+ presentSheet,+ ToastEvent+} from '../../services/EventManager';+import { db } from '../../utils/database';+import { SIZE } from '../../utils/SizeUtils';+import Input from '../Input';+import Heading from '../Typography/Heading';+import { Button } from '../Button';+import PremiumService from '../../services/PremiumService';+import { useUserStore } from '../../provider/stores';+import { clearMessage } from '../../services/Message';+import { sleep } from '../../utils/TimeUtils';+import Paragraph from '../Typography/Paragraph';+import { ActionIcon } from '../ActionIcon';+import { Toast } from '../Toast';+import { Notice } from '../Notice';+import { Dialog } from '../Dialog';+import { presentDialog } from '../Dialog/functions';++function getEmail(email) {+ if (!email) return null;+ return email.replace(/(.{2})(.*)(?=@)/, function (gp1, gp2, gp3) {+ for (let i = 0; i < gp3.length; i++) {+ gp2 += '*';+ }+ return gp2;+ });+}++export const SessionExpired = () => {+ const [state, dispatch] = useTracked();+ const colors = state.colors;+ const email = useRef();+ const emailInputRef = useRef();+ const passwordInputRef = useRef();+ const password = useRef();+ const [visible, setVisible] = useState(false);+ const [focused, setFocused] = useState(false);++ const setUser = useUserStore(state => state.setUser);++ const [error, setError] = useState(false);+ const [loading, setLoading] = useState(false);++ const logout = async () => {+ try {+ await db.user.logout();+ await BiometricService.resetCredentials();+ await Storage.write('introCompleted', 'true');+ setVisible(false);+ } catch (e) {+ ToastEvent.show({+ heading: e.message,+ type: 'error',+ context: 'local'+ });+ }+ };++ useEffect(() => {+ eSubscribeEvent('session_expired', open);+ return () => {+ eUnSubscribeEvent('session_expired', open);+ setFocused(false);+ };+ }, [visible]);++ const open = async () => {+ try {+ console.log('REQUESTING NEW TOKEN');+ let res = await db.user.tokenManager.getToken();+ if (!res) throw new Error('no token found');+ if (db.user.tokenManager._isTokenExpired(res)) throw new Error('token expired');+ if (!(await Sync.run())) throw new Error('e');+ await MMKV.removeItem('loginSessionHasExpired');+ setVisible(false);+ } catch (e) {+ console.log(e);+ let user = await db.user.getUser();+ if (!user) return;+ email.current = user.email;+ setVisible(true);+ }+ };++ const login = async () => {+ if (error) return;+ setLoading(true);+ let user;+ try {+ await db.user.login(email.toLowerCase(), password);+ user = await db.user.getUser();+ if (!user) throw new Error('Email or password incorrect!');+ PremiumService.setPremiumStatus();+ setUser(user);+ clearMessage();+ ToastEvent.show({+ heading: 'Login successful',+ message: `Logged in as ${user.email}`,+ type: 'success',+ context: 'global'+ });+ setVisible(false);+ await MMKV.removeItem('loginSessionHasExpired');+ eSendEvent('userLoggedIn', true);+ await sleep(500);+ presentSheet({+ title: 'Syncing your data',+ paragraph: 'Please wait while we sync all your data.',+ progress: true+ });+ } catch (e) {+ setLoading(false);+ ToastEvent.show({+ heading: user ? 'Failed to sync' : 'Login failed',+ message: e.message,+ type: 'error',+ context: 'local'+ });+ }+ };++ return (+ visible && (+ <Modal+ onShow={async () => {+ await sleep(300);+ passwordInputRef.current?.focus();+ setFocused(true);+ }}+ visible={true}+ >+ <View+ style={{+ width: focused ? '100%' : '99.9%',+ padding: 12,+ justifyContent: 'center',+ flex: 1+ }}+ >+ <View+ style={{+ justifyContent: 'center',+ alignItems: 'center',+ width: '100%',+ marginBottom: 20,+ borderRadius: 10,+ paddingVertical: 20+ }}+ >+ <ActionIcon+ customStyle={{+ width: 60,+ height: 60+ }}+ name="alert"+ color={colors.errorText}+ size={50}+ />+ <Heading size={SIZE.xxxl} color={colors.heading}>+ Session expired+ </Heading>+ <Paragraph+ style={{+ textAlign: 'center'+ }}+ >+ Your session on this device has expired. Please enter password for{' '}+ {getEmail(email.current)} to continue.+ </Paragraph>+ </View>++ <Input+ fwdRef={passwordInputRef}+ onChangeText={value => {+ password.current = value;+ }}+ returnKeyLabel="Next"+ returnKeyType="next"+ secureTextEntry+ autoCompleteType="password"+ autoCapitalize="none"+ autoCorrect={false}+ placeholder="Password"+ onSubmit={login}+ />++ <Button+ style={{+ marginTop: 10,+ width: '100%'+ }}+ loading={loading}+ onPress={login}+ type="accent"+ title={loading ? null : 'Login'}+ />++ <Button+ style={{+ marginTop: 10,+ width: '100%'+ }}+ onPress={() => {+ presentDialog({+ context: 'session_expiry',+ title: 'Logout',+ paragraph:+ 'Are you sure you want to logout from this device? Any unsynced changes will be lost.',+ positiveText: 'Logout',+ positiveType: 'errorShade',+ positivePress: logout+ });+ }}+ loading={loading}+ type="errorShade"+ title={loading ? null : 'Logout from this device'}+ />+ </View>+ <Toast context="local" />+ <Dialog context="session_expiry" />+ </Modal>+ )+ );+};diff --git a/apps/mobile/src/components/LoginDialog/signup.js b/apps/mobile/src/components/LoginDialog/signup.jsnew file mode 100644index 000000000..1ebc8fb41--- /dev/null+++ b/apps/mobile/src/components/LoginDialog/signup.js@@ -0,0 +1,243 @@+import React, { useRef, useState } from 'react';+import { View } from 'react-native';+import { useTracked } from '../../provider';+import { useUserStore } from '../../provider/stores';+import { DDS } from '../../services/DeviceDetection';+import { eSendEvent, ToastEvent } from '../../services/EventManager';+import { clearMessage, setEmailVerifyMessage } from '../../services/Message';+import { db } from '../../utils/database';+import { eCloseLoginDialog, eOpenResultDialog } from '../../utils/Events';+import { SIZE } from '../../utils/SizeUtils';+import { sleep } from '../../utils/TimeUtils';+import umami from '../../utils/umami';+import { ActionIcon } from '../ActionIcon';+import { Button } from '../Button';+import BaseDialog from '../Dialog/base-dialog';+import Input from '../Input';+import { SvgToPngView } from '../ListPlaceholders';+import Heading from '../Typography/Heading';+import Paragraph from '../Typography/Paragraph';+import { SVG } from './background';++export const Signup = ({ changeMode, welcome }) => {+ const [state, dispatch] = useTracked();+ const colors = state.colors;+ const email = useRef();+ const emailInputRef = useRef();+ const passwordInputRef = useRef();+ const password = useRef();+ const confirmPasswordInputRef = useRef();+ const confirmPassword = useRef();+ const [error, setError] = useState(false);+ const [loading, setLoading] = useState(false);++ const setUser = useUserStore(state => state.setUser);+ const setLastSynced = useUserStore(state => state.setLastSynced);++ const validateInfo = () => {+ if (!password.current || !email.current || !confirmPassword.current) {+ ToastEvent.show({+ heading: 'All fields required',+ message: 'Fill all the fields and try again',+ type: 'error',+ context: 'local'+ });++ return false;+ }++ return true;+ };++ const signup = async () => {+ if (!validateInfo() || error) return;+ setLoading(true);+ try {+ await db.user.signup(email.toLowerCase(), password);+ let user = await db.user.getUser();+ setUser(user);+ setLastSynced(await db.lastSynced());+ clearMessage();+ setEmailVerifyMessage();+ eSendEvent(eCloseLoginDialog);+ umami.pageView('/account-created', '/welcome/signup');+ await sleep(300);+ eSendEvent(eOpenResultDialog);+ } catch (e) {+ setLoading(false);+ ToastEvent.show({+ heading: 'Signup failed',+ message: e.message,+ type: 'error',+ context: 'local'+ });+ }+ };++ return (+ <>+ {!welcome && (+ <ActionIcon+ name="arrow-left"+ onPress={() => {+ eSendEvent(eCloseLoginDialog);+ }}+ color={colors.pri}+ customStyle={{+ position: 'absolute',+ zIndex: 999,+ left: 12,+ top: 12+ }}+ />+ )}++ {loading ? <BaseDialog transparent={true} visible={true} animation="fade" /> : null}+ <View+ style={{+ borderRadius: DDS.isTab ? 5 : 0,+ backgroundColor: colors.bg,+ zIndex: 10,+ width: '100%',+ minHeight: '100%'+ }}+ >+ <View+ style={{+ height: 250,+ overflow: 'hidden'+ }}+ >+ <SvgToPngView src={SVG(colors.night ? 'white' : 'black')} height={700} />+ </View>++ <View+ style={{+ width: '100%',+ justifyContent: 'center',+ alignSelf: 'center',+ paddingHorizontal: 12,+ marginBottom: 30,+ marginTop: 15+ }}+ >+ <Heading+ style={{+ textAlign: 'center'+ }}+ size={30}+ color={colors.heading}+ >+ Create an account+ </Heading>+ <Paragraph+ style={{+ textDecorationLine: 'underline',+ textAlign: 'center'+ }}+ onPress={() => {+ changeMode(0);+ }}+ size={SIZE.md}+ >+ Already have an account? Log in+ </Paragraph>+ </View>+ <View+ style={{+ width: '100%',+ padding: 12,+ backgroundColor: colors.bg,+ flexGrow: 1+ }}+ >+ <Input+ fwdRef={emailInputRef}+ onChangeText={value => {+ email.current = value;+ }}+ onErrorCheck={e => setError(e)}+ returnKeyLabel="Next"+ returnKeyType="next"+ autoCompleteType="email"+ validationType="email"+ autoCorrect={false}+ autoCapitalize="none"+ errorMessage="Email is invalid"+ placeholder="Email"+ onSubmit={() => {}}+ />++ <Input+ fwdRef={passwordInputRef}+ onChangeText={value => {+ password.current = value;+ }}+ onErrorCheck={e => setError(e)}+ returnKeyLabel="Next"+ returnKeyType="next"+ secureTextEntry+ autoCompleteType="password"+ autoCapitalize="none"+ validationType="password"+ autoCorrect={false}+ placeholder="Password"+ />++ <Input+ fwdRef={confirmPasswordInputRef}+ onChangeText={value => {+ confirmPassword.current = value;+ }}+ onErrorCheck={e => setError(e)}+ returnKeyLabel="Signup"+ returnKeyType="done"+ secureTextEntry+ autoCompleteType="password"+ autoCapitalize="none"+ autoCorrect={false}+ validationType="confirmPassword"+ customValidator={() => password.current}+ placeholder="Confirm password"+ marginBottom={5}+ />+ <Paragraph size={SIZE.xs} color={colors.icon}>+ By signing up, you agree to our terms of service and privacy policy.+ </Paragraph>++ <View+ style={{+ // position: 'absolute',+ marginTop: 50,+ alignSelf: 'center'+ }}+ >+ <Button+ style={{+ marginTop: 10,+ width: 250,+ borderRadius: 100+ }}+ loading={loading}+ onPress={signup}+ type="accent"+ title={loading ? null : 'Agree and continue'}+ />++ {loading || !welcome ? null : (+ <Button+ style={{+ marginTop: 10,+ width: 250,+ borderRadius: 100+ }}+ type="grayBg"+ title="Skip for now"+ />+ )}+ </View>+ </View>+ </View>+ </>+ );+};diff --git a/apps/mobile/src/components/Notice/index.js b/apps/mobile/src/components/Notice/index.jsnew file mode 100644index 000000000..4094842a6--- /dev/null+++ b/apps/mobile/src/components/Notice/index.js@@ -0,0 +1,31 @@+import React from 'react';+import { View } from 'react-native';+import { useTracked } from '../../provider';+import { ActionIcon } from '../ActionIcon';+import Paragraph from '../Typography/Paragraph';++export const Notice = ({ type, text }) => {+ const [state] = useTracked();+ const colors = state.colors;++ return (+ <View+ style={{+ padding: 12,+ flexDirection: 'row',+ backgroundColor: colors.nav,+ borderRadius: 10+ }}+ >+ <ActionIcon name={type} color={type === 'alert' ? colors.errorText : colors.icon} />+ <Paragraph+ style={{+ marginLeft: 10,+ flexShrink: 1+ }}+ >+ {text}+ </Paragraph>+ </View>+ );+};diff --git a/apps/mobile/src/components/Sheet/index.js b/apps/mobile/src/components/Sheet/index.jsindex 6f87da855..8f8957f12 100644--- a/apps/mobile/src/components/Sheet/index.js+++ b/apps/mobile/src/components/Sheet/index.js@@ -17,7 +17,9 @@ const SheetWrapper = ({onOpen,closeOnTouchBackdrop = true,onHasReachedTop,- keyboardMode+ keyboardMode,+ overlay,+ overlayOpacity = 0.3}) => {const [state] = useTracked();const { colors } = state;@@ -74,10 +76,12 @@ const SheetWrapper = ({indicatorColor={colors.nav}onOpen={_onOpen}keyboardDismissMode="none"+ defaultOverlayOpacity={overlayOpacity}overlayColor={pitchBlack ? '#585858' : '#000000'}keyboardShouldPersistTaps="always"ExtraOverlayComponent={<>+ {overlay}<Toast context="local" /><PremiumToast context="sheet" close={() => fwdRef?.current?.hide()} offset={50} /></>diff --git a/apps/mobile/src/utils/useAppEvents.js b/apps/mobile/src/utils/useAppEvents.jsindex 31a49bfe2..81468ed0c 100644--- a/apps/mobile/src/utils/useAppEvents.js+++ b/apps/mobile/src/utils/useAppEvents.js@@ -132,7 +132,7 @@ export const useAppEvents = () => {const onSessionExpired = async () => {await Storage.write('loginSessionHasExpired', 'expired');- eSendEvent(eOpenLoginDialog, 4);+ eSendEvent('session_expired');};// const onNoteRemoved = async id => {diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.jsindex 47fc74f84..204b6088b 100755--- a/apps/mobile/src/views/Home/index.js+++ b/apps/mobile/src/views/Home/index.js@@ -1,5 +1,6 @@import React, { useCallback, useEffect } from 'react';import { StatusBar } from 'react-native-bars';+import { ChangePassword } from '../../components/LoginDialog/change-password';import { ContainerBottomButton } from '../../components/Container/ContainerBottomButton';import { ContainerTopSection } from '../../components/Container/ContainerTopSection';import { Header } from '../../components/Header/index';@@ -80,6 +81,8 @@ export const Home = ({ navigation }) => {};const _onPressBottomButton = React.useCallback(async () => {+ eSendEvent('session_expired');+ return;if (!DDS.isTab) {if (getNote()) {eSendEvent(eOnLoadNote, { type: 'new' });diff --git a/apps/mobile/src/views/Settings/usersection.js b/apps/mobile/src/views/Settings/usersection.jsindex 3dbf41cd1..b42ad9965 100644--- a/apps/mobile/src/views/Settings/usersection.js+++ b/apps/mobile/src/views/Settings/usersection.js@@ -3,6 +3,7 @@ import React from 'react';import { Linking, Platform, View } from 'react-native';import * as RNIap from 'react-native-iap';import Icon from 'react-native-vector-icons/MaterialCommunityIcons';+import { ChangePassword } from '../../components/LoginDialog/change-password';import { Button } from '../../components/Button';import Seperator from '../../components/Seperator';import Heading from '../../components/Typography/Heading';@@ -269,7 +270,7 @@ const SettingsUserSection = () => {{name: 'Change password',func: async () => {- eSendEvent(eOpenLoginDialog, 3);+ ChangePassword.present();},desc: 'Setup a new password for your account.'},diff --git a/apps/mobile/tsconfig.json b/apps/mobile/tsconfig.jsonindex 0925b654d..ca3fde4a8 100644--- a/apps/mobile/tsconfig.json+++ b/apps/mobile/tsconfig.json@@ -14,11 +14,5 @@"esModuleInterop": true,"skipLibCheck": false},- "include": ["./node_modules/notes-core","."],- "exclude": [- "node_modules",- "babel.config.js",- "metro.config.js",- "jest.config.js"- ]+ "exclude": ["node_modules", "babel.config.js", "metro.config.js", "jest.config.js"]}