fix signup user

This commit is contained in:
ammarahm-ed
2020-12-20 12:48:08 +05:00
parent afa481a098
commit 1e01974635
7 changed files with 109 additions and 75 deletions

View File

@@ -4,5 +4,6 @@
<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>

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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',
});

View File

@@ -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 = {

View File

@@ -340,7 +340,8 @@ const SettingsUserSection = () => {
return ( return (
<> <>
{messageBoardState && <PressableButton {messageBoardState && messageBoardState?.visible && (
<PressableButton
onPress={messageBoardState.onPress} onPress={messageBoardState.onPress}
customStyle={{ customStyle={{
paddingVertical: 12, paddingVertical: 12,
@@ -348,12 +349,13 @@ const SettingsUserSection = () => {
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
justifyContent: 'flex-start', justifyContent: 'flex-start',
paddingHorizontal: 6, paddingHorizontal: 0,
}}> }}>
<View <View
style={{ style={{
width: 40, width: 40,
backgroundColor:messageBoardState.type === "error"? colors.red: colors.accent, backgroundColor:
messageBoardState.type === 'error' ? colors.red : colors.accent,
height: 40, height: 40,
marginLeft: 10, marginLeft: 10,
borderRadius: 100, borderRadius: 100,
@@ -370,7 +372,12 @@ const SettingsUserSection = () => {
<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
color={
messageBoardState.type === 'error' ? colors.red : colors.accent
}>
{messageBoardState.actionText}
</Paragraph>
</View> </View>
<View <View
@@ -382,9 +389,16 @@ const SettingsUserSection = () => {
position: 'absolute', position: 'absolute',
right: 6, right: 6,
}}> }}>
<Icon name="chevron-right" color={messageBoardState.type === "error"? colors.red: colors.accent} size={SIZE.lg} /> <Icon
name="chevron-right"
color={
messageBoardState.type === 'error' ? colors.red : colors.accent
}
size={SIZE.lg}
/>
</View> </View>
</PressableButton>} </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>
<View>
{user.subscription.type === 1 ||
user.subscription.type === 2 ? (
<View>
<Seperator /> <Seperator />
<View>
{user.subscription.status === 1 ? (
<View>
<Paragraph <Paragraph
size={SIZE.lg} size={SIZE.lg}
color={ color={
@@ -470,8 +487,9 @@ const SettingsUserSection = () => {
</View> </View>
) : null} ) : null}
{user.isEmailConfirmed && (
<>
<Seperator /> <Seperator />
<Button <Button
onPress={() => { onPress={() => {
eSendEvent(eOpenPremiumDialog); eSendEvent(eOpenPremiumDialog);
@@ -482,6 +500,8 @@ const SettingsUserSection = () => {
height={50} height={50}
type="accent" type="accent"
/> />
</>
)}
</View> </View>
</View> </View>
</View> </View>