mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
fix signup user
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
<domain-config cleartextTrafficPermitted="true">
|
<domain-config cleartextTrafficPermitted="true">
|
||||||
<domain includeSubdomains="true">10.0.2.2</domain>
|
<domain includeSubdomains="true">10.0.2.2</domain>
|
||||||
<domain includeSubdomains="true">localhost</domain>
|
<domain includeSubdomains="true">localhost</domain>
|
||||||
<domain includeSubdomains="true">192.168.10.5</domain>
|
<domain includeSubdomains="true">192.168.10.5</domain>
|
||||||
|
<domain includeSubdomains="true">192.168.10.10</domain>
|
||||||
</domain-config>
|
</domain-config>
|
||||||
</network-security-config>
|
</network-security-config>
|
||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
eUnSubscribeEvent,
|
eUnSubscribeEvent,
|
||||||
ToastEvent,
|
ToastEvent,
|
||||||
} from '../../services/EventManager';
|
} from '../../services/EventManager';
|
||||||
import {clearMessage} from '../../services/Message';
|
import {clearMessage, setEmailVerifyMessage} from '../../services/Message';
|
||||||
import {getElevation} from '../../utils';
|
import {getElevation} from '../../utils';
|
||||||
import {db} from '../../utils/DB';
|
import {db} from '../../utils/DB';
|
||||||
import {
|
import {
|
||||||
@@ -177,8 +177,10 @@ const LoginDialog = () => {
|
|||||||
try {
|
try {
|
||||||
await db.user.login(email.toLowerCase(), password, true);
|
await db.user.login(email.toLowerCase(), password, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
ToastEvent.show(e.message, 'error', 'local');
|
ToastEvent.show(e.message, 'error', 'local');
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
setStatus(null)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,6 +199,7 @@ const LoginDialog = () => {
|
|||||||
ToastEvent.show(`Logged in as ${email}`, 'success', 'local');
|
ToastEvent.show(`Logged in as ${email}`, 'success', 'local');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn(e);
|
console.warn(e);
|
||||||
|
setStatus(null);
|
||||||
ToastEvent.show(e.message, 'error', 'local');
|
ToastEvent.show(e.message, 'error', 'local');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -241,6 +244,8 @@ const LoginDialog = () => {
|
|||||||
await db.user.signup(email, password);
|
await db.user.signup(email, password);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
setStatus(null);
|
||||||
|
console.log(e);
|
||||||
ToastEvent.show('Signup failed, Network Error', 'error', 'local');
|
ToastEvent.show('Signup failed, Network Error', 'error', 'local');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -253,10 +258,12 @@ const LoginDialog = () => {
|
|||||||
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
|
dispatch({type: Actions.LAST_SYNC, lastSync: await db.lastSynced()});
|
||||||
eSendEvent(eStartSyncer);
|
eSendEvent(eStartSyncer);
|
||||||
clearMessage(dispatch);
|
clearMessage(dispatch);
|
||||||
|
setEmailVerifyMessage(dispatch)
|
||||||
close();
|
close();
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
eSendEvent(eOpenRecoveryKeyDialog, true);
|
eSendEvent(eOpenRecoveryKeyDialog, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
setStatus(null);
|
||||||
ToastEvent.show('Login Failed, try again', 'error', 'local');
|
ToastEvent.show('Login Failed, try again', 'error', 'local');
|
||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
@@ -559,7 +566,6 @@ const LoginDialog = () => {
|
|||||||
onPress={current.buttonAltFunc}
|
onPress={current.buttonAltFunc}
|
||||||
width="100%"
|
width="100%"
|
||||||
type="shade"
|
type="shade"
|
||||||
loading={loading}
|
|
||||||
fontSize={SIZE.md}
|
fontSize={SIZE.md}
|
||||||
style={{
|
style={{
|
||||||
marginTop: 10,
|
marginTop: 10,
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ export const MenuListItem = ({item, index, noTextMode, testID}) => {
|
|||||||
/>
|
/>
|
||||||
{headerTextState?.id === item.name.toLowerCase() + '_navigation' ? (
|
{headerTextState?.id === item.name.toLowerCase() + '_navigation' ? (
|
||||||
<Heading color={colors.accent} size={SIZE.md}>
|
<Heading color={colors.accent} size={SIZE.md}>
|
||||||
{item.name}
|
{item.name}
|
||||||
</Heading>
|
</Heading>
|
||||||
) : (
|
) : (
|
||||||
<Paragraph size={SIZE.md}>{item.name}</Paragraph>
|
<Paragraph size={SIZE.md}>{item.name}</Paragraph>
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class RecoveryKeyDialog extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onOpen = async () => {
|
onOpen = async () => {
|
||||||
let k = await db.user.key();
|
let k = await db.user.getEncryptionKey();
|
||||||
this.user = await db.user.getUser();
|
this.user = await db.user.getUser();
|
||||||
|
|
||||||
if (k) {
|
if (k) {
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
import {Platform} from "react-native";
|
import {Platform} from 'react-native';
|
||||||
import Storage from "./Storage";
|
import Storage from './storage';
|
||||||
import EventSource from "rn-eventsource";
|
import EventSource from 'rn-eventsource';
|
||||||
import AndroidEventSource from "./EventSource";
|
import AndroidEventSource from './event-source';
|
||||||
import Database from "notes-core/api/index";
|
import Database from 'notes-core/api/index';
|
||||||
|
|
||||||
global.Buffer = require('buffer').Buffer;
|
global.Buffer = require('buffer').Buffer;
|
||||||
export const db = new Database(
|
export const db = new Database(
|
||||||
Storage,
|
Storage,
|
||||||
Platform.OS === 'ios' ? EventSource : AndroidEventSource,
|
Platform.OS === 'ios' ? EventSource : AndroidEventSource,
|
||||||
);
|
);
|
||||||
db.host("https://api.notesnook.com")
|
|
||||||
|
//"https://api.notesnook.com"
|
||||||
|
|
||||||
|
db.host({
|
||||||
|
API_HOST: 'http://192.168.10.10:5264',
|
||||||
|
AUTH_HOST: 'http://192.168.10.10:8264',
|
||||||
|
SSE_HOST: 'http://192.168.10.10:7264',
|
||||||
|
});
|
||||||
|
|||||||
@@ -143,11 +143,11 @@ export const SUBSCRIPTION_STATUS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const SUBSCRIPTION_STATUS_STRINGS = {
|
export const SUBSCRIPTION_STATUS_STRINGS = {
|
||||||
0: 'Expired',
|
0: 'Basic',
|
||||||
1: 'Trial',
|
1: 'Trial',
|
||||||
2: 'Pro',
|
2: 'Beta',
|
||||||
3: 'Pro',
|
3: 'Trial Expired',
|
||||||
4: 'Cancelled',
|
4: 'Beta Expired',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const BUTTON_TYPES = {
|
export const BUTTON_TYPES = {
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ const CustomButton = ({
|
|||||||
|
|
||||||
const SettingsUserSection = () => {
|
const SettingsUserSection = () => {
|
||||||
const [state] = useTracked();
|
const [state] = useTracked();
|
||||||
const {colors, user,messageBoardState} = state;
|
const {colors, user, messageBoardState} = state;
|
||||||
|
|
||||||
const getTimeLeft = (t2) => {
|
const getTimeLeft = (t2) => {
|
||||||
let d1 = new Date(Date.now());
|
let d1 = new Date(Date.now());
|
||||||
@@ -340,51 +340,65 @@ const SettingsUserSection = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{messageBoardState && <PressableButton
|
{messageBoardState && messageBoardState?.visible && (
|
||||||
onPress={messageBoardState.onPress}
|
<PressableButton
|
||||||
customStyle={{
|
onPress={messageBoardState.onPress}
|
||||||
paddingVertical: 12,
|
customStyle={{
|
||||||
width: '100%',
|
paddingVertical: 12,
|
||||||
flexDirection: 'row',
|
width: '100%',
|
||||||
alignItems: 'center',
|
flexDirection: 'row',
|
||||||
justifyContent: 'flex-start',
|
|
||||||
paddingHorizontal: 6,
|
|
||||||
}}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
width: 40,
|
|
||||||
backgroundColor:messageBoardState.type === "error"? colors.red: colors.accent,
|
|
||||||
height: 40,
|
|
||||||
marginLeft: 10,
|
|
||||||
borderRadius: 100,
|
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'flex-start',
|
||||||
|
paddingHorizontal: 0,
|
||||||
}}>
|
}}>
|
||||||
<Icon size={SIZE.lg} color="white" name={messageBoardState.icon} />
|
<View
|
||||||
</View>
|
style={{
|
||||||
|
width: 40,
|
||||||
|
backgroundColor:
|
||||||
|
messageBoardState.type === 'error' ? colors.red : colors.accent,
|
||||||
|
height: 40,
|
||||||
|
marginLeft: 10,
|
||||||
|
borderRadius: 100,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
}}>
|
||||||
|
<Icon size={SIZE.lg} color="white" name={messageBoardState.icon} />
|
||||||
|
</View>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
marginLeft: 10,
|
marginLeft: 10,
|
||||||
}}>
|
}}>
|
||||||
<Paragraph color={colors.icon} size={SIZE.xs}>
|
<Paragraph color={colors.icon} size={SIZE.xs}>
|
||||||
{messageBoardState.message}
|
{messageBoardState.message}
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Paragraph color={messageBoardState.type === "error"? colors.red: colors.accent}>{messageBoardState.actionText}</Paragraph>
|
<Paragraph
|
||||||
</View>
|
color={
|
||||||
|
messageBoardState.type === 'error' ? colors.red : colors.accent
|
||||||
|
}>
|
||||||
|
{messageBoardState.actionText}
|
||||||
|
</Paragraph>
|
||||||
|
</View>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
width: 40,
|
width: 40,
|
||||||
height: 40,
|
height: 40,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
right: 6,
|
right: 6,
|
||||||
}}>
|
}}>
|
||||||
<Icon name="chevron-right" color={messageBoardState.type === "error"? colors.red: colors.accent} size={SIZE.lg} />
|
<Icon
|
||||||
</View>
|
name="chevron-right"
|
||||||
</PressableButton>}
|
color={
|
||||||
|
messageBoardState.type === 'error' ? colors.red : colors.accent
|
||||||
|
}
|
||||||
|
size={SIZE.lg}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</PressableButton>
|
||||||
|
)}
|
||||||
|
|
||||||
{user ? (
|
{user ? (
|
||||||
<>
|
<>
|
||||||
@@ -396,7 +410,6 @@ const SettingsUserSection = () => {
|
|||||||
style={{
|
style={{
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
borderRadius: 5,
|
|
||||||
paddingVertical: 12,
|
paddingVertical: 12,
|
||||||
}}>
|
}}>
|
||||||
<View
|
<View
|
||||||
@@ -404,6 +417,9 @@ const SettingsUserSection = () => {
|
|||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
borderBottomWidth:1,
|
||||||
|
paddingBottom:2.5,
|
||||||
|
borderBottomColor:colors.nav
|
||||||
}}>
|
}}>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@@ -443,14 +459,15 @@ const SettingsUserSection = () => {
|
|||||||
paddingVertical: 2.5,
|
paddingVertical: 2.5,
|
||||||
}}>
|
}}>
|
||||||
<Heading color={colors.accent} size={SIZE.sm}>
|
<Heading color={colors.accent} size={SIZE.sm}>
|
||||||
{SUBSCRIPTION_STATUS_STRINGS[user.subscription.status]}
|
{SUBSCRIPTION_STATUS_STRINGS[user.subscription.type]}
|
||||||
</Heading>
|
</Heading>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<Seperator />
|
|
||||||
<View>
|
<View>
|
||||||
{user.subscription.status === 1 ? (
|
{user.subscription.type === 1 ||
|
||||||
|
user.subscription.type === 2 ? (
|
||||||
<View>
|
<View>
|
||||||
|
<Seperator />
|
||||||
<Paragraph
|
<Paragraph
|
||||||
size={SIZE.lg}
|
size={SIZE.lg}
|
||||||
color={
|
color={
|
||||||
@@ -470,18 +487,21 @@ const SettingsUserSection = () => {
|
|||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
<Seperator />
|
{user.isEmailConfirmed && (
|
||||||
|
<>
|
||||||
<Button
|
<Seperator />
|
||||||
onPress={() => {
|
<Button
|
||||||
eSendEvent(eOpenPremiumDialog);
|
onPress={() => {
|
||||||
}}
|
eSendEvent(eOpenPremiumDialog);
|
||||||
width="100%"
|
}}
|
||||||
fontSize={SIZE.md}
|
width="100%"
|
||||||
title="Subscribe to Notesnook Pro"
|
fontSize={SIZE.md}
|
||||||
height={50}
|
title="Subscribe to Notesnook Pro"
|
||||||
type="accent"
|
height={50}
|
||||||
/>
|
type="accent"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user