log in testing

This commit is contained in:
Maria Sanchez 2022-08-21 17:25:22 -06:00
parent 8149ade113
commit 66511f4e8a
3 changed files with 117 additions and 87 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -17,7 +17,16 @@
"**/*" "**/*"
], ],
"ios": { "ios": {
"supportsTablet": true "supportsTablet": true,
"infoPlist": {
"NSAppTransportSecurity": {
"NSAllowsArbitraryLoads" : true,
"NSAllowsArbitraryLoadsForMedia": true,
"NSAllowsArbitraryLoadsInWebContent": true,
"NSExceptionAllowsInsecureHTTPLoads": true
}
},
"bundleIdentifier": "1.1.0"
}, },
"android": { "android": {
"adaptiveIcon": { "adaptiveIcon": {

View File

@ -1,4 +1,4 @@
import React from "react"; import React, {useState} from "react";
import Cookies from 'universal-cookie'; import Cookies from 'universal-cookie';
import { import {
Text, Text,
@ -19,53 +19,36 @@ import { View, TextInput, StyleSheet } from "react-native";
const baseURL = "http://localhost:4000/user/loginUser"; const baseURL = "http://localhost:4000/user/loginUser";
const cookies = new Cookies(); const cookies = new Cookies();
const styles = StyleSheet.create({ // const handleChange = (value) => {
input: { // console.log(value);
height: 40,
margin: 10,
borderWidth: 0.5,
padding: 5,
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
paddingLeft: 0,
marginTop: 50,
marginBottom: 10,
borderRadius: 4
},
iconStyle: { // }
paddingBottom: 20,
marginTop: 3,
paddingTop: 35
},
viewSection: { export default function LogIn({navigation}) {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
marginBottom: 28 const [email, setEmail] = useState();
}, const [password, setPassword] = useState();
// const [inputs, setInputs] = useState();
container: { const iniciarSesion = async () => {
console.log(email);
const userData = {
email: "lalo@lalo.com",
password: '65bbb27d640914c507e5af778eccf3d1'
} }
})
const iniciarSesion = async() => {
const userData = JSON.stringify(FormControl.toString);
console.log(userData); console.log(userData);
// const userData = JSON.stringify(FormControl.toString);
// console.log(userData);
try { try {
await fetch(baseURL, { await fetch(baseURL, {
cache: 'no-cache', cache: 'no-cache',
method: 'POST', method: 'POST',
body: JSON.stringify(), body: JSON.stringify(userData),
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
@ -78,29 +61,33 @@ const iniciarSesion = async() => {
} }
}) })
.then( response => { .then( response => {
// inqulino 4 y guarda 63
const user = response.message const user = response.message
cookies.set('id',user._id, {path: "/"} ) cookies.set('id',user._id, {path: "/"} )
cookies.set('name',user.name, {path: "/"} ) cookies.set('name',user.name, {path: "/"} )
cookies.set('email',user.email, {path: "/"} ) cookies.set('email',user.email, {path: "/"} )
cookies.set('type',user.user_type, {path: "/"} ) cookies.set('type',user.user_type, {path: "/"} )
if(user.user_type == '3'){ if(user.user_type == '4'){
navigation.navigate('Comunicados') navigation.navigate('Comunicados')
}else if(user.user_type == '4'){ }else if(user.user_type == '3'){
} }
}) })
} catch (error) { } catch (error) {
console.log("ERROR: " +error);
} }
} }
export default function LogIn({navigation}) {
return ( return (
@ -144,15 +131,15 @@ export default function LogIn({navigation}) {
<View style={styles.viewSection}> <View style={styles.viewSection}>
<Entypo name="email" size={20} color="grey" style={styles.iconStyle} /> <Entypo name="email" size={20} color="grey" style={styles.iconStyle} />
<TextInput type="text" style={styles.input} placeholder='Correo Electrónico' /> <TextInput name='email' type="text" style={styles.input} placeholder='Correo electrónico' onChangeText={(value) => setEmail(value) } />
</View> </View>
</FormControl> </FormControl>
<FormControl isRequired> <FormControl isRequired>
<FormControl.Label> Contraseña </FormControl.Label> <FormControl.Label Text='bold'> Contraseña </FormControl.Label>
<View style={styles.viewSection}> <View style={styles.viewSection}>
<MaterialCommunityIcons name="form-textbox-password" size={20} color="grey" style={styles.iconStyle}/> <MaterialCommunityIcons name="form-textbox-password" size={20} color="grey" style={styles.iconStyle}/>
<TextInput type="password" style={styles.input} placeholder='Contraseña' /> <TextInput name='password' type="password" style={styles.input} placeholder='Contraseña' onChangeText={(value) => setPassword(value)} />
</View> </View>
<Link <Link
_text={{ _text={{
@ -182,6 +169,40 @@ export default function LogIn({navigation}) {
</Center> </Center>
); );
} }
const styles = StyleSheet.create({
input: {
height: 40,
margin: 10,
borderWidth: 0.5,
padding: 5,
flex: 1,
paddingTop: 10,
paddingRight: 10,
paddingBottom: 10,
paddingLeft: 0,
marginTop: 50,
marginBottom: 10,
borderRadius: 4
},
iconStyle: {
paddingBottom: 20,
marginTop: 3,
paddingTop: 35
},
viewSection: {
flex: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
marginBottom: 28
},
container: {
}
})