This commit is contained in:
henrydays 2019-01-31 00:57:24 +00:00
commit 6d57eb4e5a
4 changed files with 71 additions and 15 deletions

View File

@ -0,0 +1,31 @@
const axios = require('axios');
const url = "http://enei2019.uingress.com/internal/api/token";
export function getToken(userName, password) {
let headers = {
header: {
'Content-Type': 'application/x-www-form-urlencoded',
}
};
let request = {
method: 'GET',
headers: headers,
body: {
username: userName,
password: password,
grant_type: 'password'
}
};
fetch(url, request).then(response => {
return response.json()
})
.catch(function(error) {
console.log('There has been a problem with your fetch operation: ' + error.message);
// ADD THIS THROW error
throw error;
});
};

View File

@ -1,6 +1,5 @@
import React from 'react';
import {TouchableOpacity} from 'react-native';
import {
createStackNavigator,
createAppContainer,
@ -12,7 +11,6 @@ import Login from './screens/Login'
import AuthLoadingScreen from './screens/AuthLoading'
import Eventos from './screens/Eventos'
import Social from './screens/Social'
@ -23,7 +21,6 @@ import Home from './screens/Home'
import logout from './screens/logout'
/*Icons*/
import Icon from "react-native-vector-icons/Ionicons"
import IconF from "react-native-vector-icons/Foundation"
@ -143,9 +140,9 @@ const AuthStack = createStackNavigator(
export default createAppContainer(createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
App: AppStack,
App: Stack,
Auth: AuthStack,
},
{
initialRouteName: 'App'

View File

@ -1,9 +1,19 @@
import React, { Component } from 'react';
import React, {Component} from 'react';
import { Button, View, Text , TouchableOpacity, FlatList, ActivityIndicator} from 'react-native';
import {bindActionCreators} from 'redux';
import {
RkButton,
RkTheme
} from 'react-native-ui-kitten';
import { connect } from 'react-redux';
import {bindActionCreators} from 'redux';
import * as Actions from '../actions'; //Import your actionss
import Counter from './Counter'
import {createStore} from 'redux';
import {Provider} from 'react-redux'
class Home extends Component {
@ -25,6 +35,7 @@ class Home extends Component {
componentDidMount() {
//this.props.logoutUser();
this.props.getUserInfo();
@ -50,6 +61,7 @@ class Home extends Component {
this.props.logoutUser();
}
render() {
const { navigate } = this.props.navigation;
if(this.props.token){
@ -93,6 +105,8 @@ class Home extends Component {
</Text>
</View>
)
}
}

28
App/package-lock.json generated
View File

@ -2953,11 +2953,13 @@
},
"balanced-match": {
"version": "1.0.0",
"bundled": true
"bundled": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -2970,15 +2972,18 @@
},
"code-point-at": {
"version": "1.1.0",
"bundled": true
"bundled": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true
"bundled": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true
"bundled": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -3081,7 +3086,8 @@
},
"inherits": {
"version": "2.0.3",
"bundled": true
"bundled": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -3091,6 +3097,7 @@
"is-fullwidth-code-point": {
"version": "1.0.0",
"bundled": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -3103,17 +3110,20 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
},
"minimist": {
"version": "0.0.8",
"bundled": true
"bundled": true,
"optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@ -3130,6 +3140,7 @@
"mkdirp": {
"version": "0.5.1",
"bundled": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -3202,7 +3213,8 @@
},
"number-is-nan": {
"version": "1.0.1",
"bundled": true
"bundled": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -3212,6 +3224,7 @@
"once": {
"version": "1.4.0",
"bundled": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -3317,6 +3330,7 @@
"string-width": {
"version": "1.0.2",
"bundled": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",