Skip to content

Commit 1b89f72

Browse files
committed
updated CosynJWT Expo create account
1 parent adf503e commit 1b89f72

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

CosyncJWT/ReactNative-Expo/ExpoCosyncJWT/screens/Register.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// Copyright © 2022 cosync. All rights reserved.
2424
//
2525

26-
import React, { useState, useRef, useEffect } from 'react';
26+
import React, { useState, useRef, useEffect, useContext } from 'react';
2727
import {
2828
TextInput,
2929
View,
@@ -37,6 +37,7 @@ import Configure from '../config/Config';
3737
import CosyncJWTReactNative from 'cosync-jwt-react-native';
3838
import Loader from '../components/Loader';
3939
import {globalStyle} from '../styles/globalStyle'
40+
import { AuthContext } from '../store/auth-context';
4041

4142
const Register = props => {
4243

@@ -54,7 +55,7 @@ const Register = props => {
5455
const ref_input_email = useRef();
5556
const ref_input_pwd = useRef();
5657
const ref_input_code = useRef();
57-
58+
const authCtx = useContext(AuthContext);
5859
global.realm = null;
5960
global.realmPrivate = null;
6061

@@ -125,9 +126,11 @@ const Register = props => {
125126

126127

127128
let metaData = {
128-
name: {
129-
first: firstName,
130-
last: lastName
129+
user_data : {
130+
name: {
131+
first: firstName,
132+
last: lastName
133+
}
131134
},
132135
email: userEmail
133136
};
@@ -149,15 +152,14 @@ const Register = props => {
149152

150153
global.cosync.register.register(userEmail, userPassword, signupCode, metaData).then(result => {
151154

152-
setLoading(false);
153-
154-
155+
setLoading(false);
155156

156157
if(result.jwt){
157158
global.userData = result;
158159
global.cosync.realmManager.login(result.jwt, Configure.Realm.appId).then(res => {
159160
setLoading(false);
160-
props.navigation.navigate('DrawerNavigationRoutes');
161+
authCtx.authenticate(result);
162+
161163
})
162164
.catch(err => {
163165
setLoading(false);

CosyncJWT/ReactNative-Expo/ExpoCosyncJWT/screens/SignUp.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ const Signup = props => {
130130
setLoading(false);
131131

132132
authCtx.authenticate(result);
133-
134-
//props.navigation.navigate('DrawerNavigationRoutes');
133+
135134
})
136135
.catch(err => {
137136
setLoading(false);
@@ -198,8 +197,7 @@ const Signup = props => {
198197
global.cosync.realmManager.login(result.jwt, Configure.Realm.appId).then(res => {
199198
setLoading(false);
200199
authCtx.authenticate(result);
201-
202-
//props.navigation.navigate('DrawerNavigationRoutes');
200+
203201
})
204202
.catch(err => {
205203
setLoading(false);

0 commit comments

Comments
 (0)