From 66511f4e8a08112974122ab7b7a3997a34a4d911 Mon Sep 17 00:00:00 2001 From: Maria Sanchez Date: Sun, 21 Aug 2022 17:25:22 -0600 Subject: [PATCH] log in testing --- .DS_Store | Bin 6148 -> 8196 bytes mobile-ui/app.json | 11 +- mobile-ui/components/LogIn.js | 193 +++++++++++++++++++--------------- 3 files changed, 117 insertions(+), 87 deletions(-) diff --git a/.DS_Store b/.DS_Store index bb3702d571f5eff6a806def746749eacf184c903..0f65b3f9acae7a1405b0629cdb6d73ec07ae3100 100644 GIT binary patch literal 8196 zcmeHMOK;Oa5T0#I>nH`ah)0D$SmK6~($La}xP*`%IB;nY8~_zR($v(kBRgq?s!BP7 z_#+63D?fl6cm4|}_-5_2w&S!?4?K6J-P!E!_wDS=cI^Jdk`^H#3_b|;F#BWIb=1K zgGfej5)qt4yt9Zi6d`v9PM6C`R3oWcWdUV@Q44VHUPQLuA&1JT{Qb=%*SAd9H?e~M zs2-p${*VPdq5`$aClfdq8Go624B+-(*)8( z8Ex1*DTZl$s%#>N<%BQx!uYknKX9#=^yT#m2d<5~OC^0}dG!o|D|P;4$VyGPtxCi4 z+Z|k_VM)!m{dzr);@XGV_g`;re1Y33v&KGkO=tJyeKJ9FsEd+kv%q8oTPQ+qj{p9D zHgbhh7El)WD=Z+U>Wz90s`8s?Ug2C@M}39Lh1U%tDIsWNIu0q*amb^87^1IZDPyX! g97GZ$D8Kwe!1!l+`pr{4|Bqgb)bn3n)qkq_3CR5}HUIzs delta 136 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGjUEV6q~50C<+o_1dHV`q%!C-lrm(d6mKkC z&dA6y*-ubuvzh2cri~38%!}DMI0Tu2ih)3Y8%Vf<4B1%toq009j3dYvkTEPEnh9bJ LSZs4V&m3j|vKbUE diff --git a/mobile-ui/app.json b/mobile-ui/app.json index 6274d58f..8e0ed902 100644 --- a/mobile-ui/app.json +++ b/mobile-ui/app.json @@ -17,7 +17,16 @@ "**/*" ], "ios": { - "supportsTablet": true + "supportsTablet": true, + "infoPlist": { + "NSAppTransportSecurity": { + "NSAllowsArbitraryLoads" : true, + "NSAllowsArbitraryLoadsForMedia": true, + "NSAllowsArbitraryLoadsInWebContent": true, + "NSExceptionAllowsInsecureHTTPLoads": true + } + }, + "bundleIdentifier": "1.1.0" }, "android": { "adaptiveIcon": { diff --git a/mobile-ui/components/LogIn.js b/mobile-ui/components/LogIn.js index 8320d19c..2978e5fb 100644 --- a/mobile-ui/components/LogIn.js +++ b/mobile-ui/components/LogIn.js @@ -1,4 +1,4 @@ -import React from "react"; +import React, {useState} from "react"; import Cookies from 'universal-cookie'; import { Text, @@ -19,88 +19,75 @@ import { View, TextInput, StyleSheet } from "react-native"; const baseURL = "http://localhost:4000/user/loginUser"; const cookies = new Cookies(); -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 - }, +// const handleChange = (value) => { +// console.log(value); - iconStyle: { - paddingBottom: 20, - marginTop: 3, - paddingTop: 35 - }, - - viewSection: { - flex: 1, - flexDirection: 'row', - justifyContent: 'center', - alignItems: 'center', - - marginBottom: 28 - }, - - container: { - - } -}) - -const iniciarSesion = async() => { - - const userData = JSON.stringify(FormControl.toString); - console.log(userData); - - try { - - await fetch(baseURL, { - cache: 'no-cache', - method: 'POST', - body: JSON.stringify(), - headers: { - 'Content-Type': 'application/json' - } - }) - .then(response => { - if (response.status != 201){ - console.log('ocurrio un error '); - }else{ - return response.json(); - } - }) - .then( response => { - const user = response.message - - cookies.set('id',user._id, {path: "/"} ) - cookies.set('name',user.name, {path: "/"} ) - cookies.set('email',user.email, {path: "/"} ) - cookies.set('type',user.user_type, {path: "/"} ) - if(user.user_type == '3'){ - - - navigation.navigate('Comunicados') - }else if(user.user_type == '4'){ - - } - }) - - } catch (error) { - - } - - -} +// } export default function LogIn({navigation}) { + + const [email, setEmail] = useState(); + const [password, setPassword] = useState(); + // const [inputs, setInputs] = useState(); + + const iniciarSesion = async () => { + + console.log(email); + + const userData = { + email: "lalo@lalo.com", + password: '65bbb27d640914c507e5af778eccf3d1' + } + + console.log(userData); + // const userData = JSON.stringify(FormControl.toString); + // console.log(userData); + + try { + + await fetch(baseURL, { + cache: 'no-cache', + method: 'POST', + body: JSON.stringify(userData), + headers: { + 'Content-Type': 'application/json' + } + }) + .then(response => { + if (response.status != 201){ + console.log('ocurrio un error '); + }else{ + return response.json(); + } + }) + .then( response => { + + // inqulino 4 y guarda 63 + const user = response.message + + cookies.set('id',user._id, {path: "/"} ) + cookies.set('name',user.name, {path: "/"} ) + cookies.set('email',user.email, {path: "/"} ) + cookies.set('type',user.user_type, {path: "/"} ) + if(user.user_type == '4'){ + + + + + + navigation.navigate('Comunicados') + }else if(user.user_type == '3'){ + + } + }) + + } catch (error) { + console.log("ERROR: " +error); + } + + + } + return ( @@ -144,15 +131,15 @@ export default function LogIn({navigation}) { - + setEmail(value) } /> - Contraseña + Contraseña - + setPassword(value)} /> ); - - -} \ No newline at end of file +} + +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: { + + } +}) \ No newline at end of file