Commit 6094c1c7 authored by tejaswi's avatar tejaswi
Browse files

Google login without firebase

parent 69cd291c
Showing with 284 additions and 72 deletions
+284 -72
......@@ -6,6 +6,7 @@ buildscript {
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
googlePlayServicesAuthVersion="17.0.0"
}
repositories {
google()
......@@ -13,6 +14,7 @@ buildscript {
}
dependencies {
classpath('com.android.tools.build:gradle:4.2.0')
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
......
rootProject.name = 'Agile'
include ':react-native-google_signin',':app'
include ':react-native-onesignal'
project(':react-native-onesignal').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-onesignal/android')
include ':react-native-svg'
......
......@@ -3160,6 +3160,11 @@
"integrity": "sha512-W/J0fNYVO01tioHjvYWQ9m6RgndVtbElzYozBq1ZPrHO/iCzlqoySHl4gO/fpCl9QEFjvJfjPgtPMTMlsoq5DQ==",
"dev": true
},
"@react-native-community/google-signin": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@react-native-community/google-signin/-/google-signin-5.0.0.tgz",
"integrity": "sha512-MvFHImmtlmE1kJZgZ9XaULm/OBuQ/AQWOCPr3NzYTUv2cCqyGwfFrealo5PS/fuL/InCGcfqK1k/1dZ+67Hjmg=="
},
"@react-native-community/masked-view": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/@react-native-community/masked-view/-/masked-view-0.1.11.tgz",
......
......@@ -297,7 +297,7 @@ export default class EmployeeInfo extends Component {
<View style={{ paddingLeft: 20 ,flexDirection:'row'}}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('ManageProjects', { empId: this.props.navigation.state.params.empId, emp_role: this.props.navigation.state.params.role })}>
{/* <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > */}
<ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>Epics</Text>
<Text style={{ paddingLeft: '85%',fontWeight: 'bold', fontSize: 15 }}>{this.state.IdeaCount}</Text>
......@@ -307,7 +307,7 @@ export default class EmployeeInfo extends Component {
</View>
<View style={{ paddingRight: 40 }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('EmployeeManageTask', { empId: this.props.navigation.state.params.empId, emp_role: this.props.navigation.state.params.role })}>
<ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>Sprint</Text>
{/* <ImageBackground source={require('../Images/maintask.png')} style={{ width: wp('40%'), height: hp('22%'), margin: 10, }} > */}
......@@ -321,12 +321,12 @@ export default class EmployeeInfo extends Component {
</View>
</View>
<View style={{ paddingTop: 20 }}>
<View style={{ paddingTop: 10 }}>
<View style={{ height: hp('18%') }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<View style={{ paddingLeft: 20 }}>
<TouchableOpacity onPress={() => this.UserCheck()}>
<ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>User Story</Text>
{/* <ImageBackground source={require('../Images/subtask.png')} style={{ width: wp('40%'), height: hp('22%'), margin: 10, }} > */}
......@@ -337,7 +337,7 @@ export default class EmployeeInfo extends Component {
</View>
<View style={{ paddingRight: 40 }}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('RoadBlockInfo', { empId: this.props.navigation.state.params.empId, emp_role: this.props.navigation.state.params.role })}>
<ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} >
{/* <ImageBackground source={require('../Images/roadblocks.png')} style={{ width: wp('40%'), height: hp('22%'), margin: 10, }} > */}
<Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>RoadBlock</Text>
......@@ -353,13 +353,13 @@ export default class EmployeeInfo extends Component {
</View>
<View style={{ paddingTop: 20 }}>
<View style={{ paddingTop: 10 }}>
<View style={{ height: hp('18%') }}>
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
<View style={{ paddingLeft: 20 ,flexDirection:'row'}}>
<TouchableOpacity onPress={() => this.props.navigation.navigate('KudosPoints', { empId: this.props.navigation.state.params.empId, emp_role: this.props.navigation.state.params.role })}>
{/* <ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} > */}
<ImageBackground style={{ width: wp('40%'), height: hp('22%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<ImageBackground style={{ width: wp('40%'), height: hp('17%'), margin: 10, backgroundColor:'#DCD9D9'}} >
<Text style={{justifyContent:'center',fontWeight: 'bold', textAlign:'center',alignContent:'center',alignItems:'center',paddingTop: 50,}}>Kudos Points</Text>
<Text style={{ paddingLeft: '85%',fontWeight: 'bold', fontSize: 15 }}>{this.state.IdeaCount}</Text>
......
......@@ -202,12 +202,12 @@ export default class ReportBug extends Component {
}
else if (bug_one_sen.length === 0) {
log("Warn", "Bug should not be empty");
// alert("Enter Bug Report");
alert("Enter Bug Report");
}
else if (steps_for_bug.length === 0) {
log("Warn", "Steps should not be empty");
// alert("Enter Steps of Bugs");
alert("Enter Steps of Bugs");
}
// else if (mobile.length === 0) {
......@@ -261,8 +261,8 @@ export default class ReportBug extends Component {
justifyContent: 'space-between',
}}>
<Left>
<Icon name="menu" size={25} style={{ color: '#fff' }} onPress={() =>
this.props.navigation.toggleDrawer()} />
<Icon size={25} name="arrow-left" style={{ color: '#fff' }} onPress={() =>
this.props.navigation.goBack(null)} />
</Left>
<Body>
<Title style={{ color: '#fff', fontWeight: '600' }}>Report Support</Title>
......
......@@ -16,7 +16,6 @@ import NetInfo from '@react-native-community/netinfo';
import Snackbar from 'react-native-snackbar';
import jwt_decode from "jwt-decode";
import {
BallIndicator,
BarIndicator,
......@@ -30,6 +29,18 @@ import {
import UserDatabase from '../OfflineDB/UserDatabase';
const db = new UserDatabase();
import RadioButtonRN from 'radio-buttons-react-native';
import {
GoogleSignin,
GoogleSigninButton,
statusCodes,
} from '@react-native-community/google-signin';
GoogleSignin.configure({
webClientId: '60924326009-0tek064dualdlt2t0remkrlh49mtqlt4.apps.googleusercontent.com',
offlineAccess: true, // if you want to access Google API on behalf
});
export default class Login extends Component {
constructor(props) {
......@@ -42,7 +53,9 @@ export default class Login extends Component {
showPass: true,
press: false,
usertype: '',
action: ''
action: '',
userGoogleInfo: {},
loaded: false
};
}
......@@ -59,8 +72,42 @@ export default class Login extends Component {
componentDidMount() {
// db.initDB();
log("Debug", "Login Screen is Loaded");
console.log("User Details")
this.signOut();
}
signOut = async () => {
try {
await GoogleSignin.signOut();
this.setState({ user: null }); // Remember to remove the user from your app's state as well
} catch (error) {
console.error(error);
}
};
signIn = async () => {
try {
console.log("asdsad");
await GoogleSignin.hasPlayServices();
const userInfo = await GoogleSignin.signIn();
this.setState({
userGoogleInfo: userInfo,
loaded: true
})
this.onSignIn2(this.state.userGoogleInfo)
console.log("data getted"+this.state.userGoogleInfo);
} catch (error) {
if (error.code === statusCodes.SIGN_IN_CANCELLED) {
console.log("e 1");
} else if (error.code === statusCodes.IN_PROGRESS) {
console.log("e 2");
} else if (error.code === statusCodes.PLAY_SERVICES_NOT_AVAILABLE) {
console.log("e 3");
} else {
console.log(error.message);
}
}
};
//Checking for Validation
isValid() {
......@@ -104,30 +151,152 @@ export default class Login extends Component {
// alert("Relogin Again")
// }
// else{
AsyncStorage.getItem("userToken", (err, res) => {
const empId = res;
AsyncStorage.getItem("userId", (err, res) => {
const userId = res;
log("Info", " addSubTask() is used to add sub task");
AsyncStorage.getItem("userToken", (err, res) => {
const empId = res;
AsyncStorage.getItem("userId", (err, res) => {
const userId = res;
log("Info", " addSubTask() is used to add sub task");
// alert("deviceid" + userId)
if (userId === null) {
alert("Your Device Id is not detected. \n Please relaunch app and Try again...")
this.setState({
username: '',
password: ''
})
})
}
else{
else {
this.onSignIn()
}
})
})
}
}
//User or Admin Login
onSignIn2(userGoogleInfo) {
// alert(JSON.stringify(userGoogleInfo))
// alert(API)
log("Info", "onSignIn1() is used for login purpose and based on usertype data is authorizised");
// console.log(username + "" + password);
fetch(API + 'sso_authentication.php', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
username: userGoogleInfo.user.email,
name: userGoogleInfo.user.name,
action: 'sso_sign_in',
// crop: cropcode,
// utype: usertype,
})
}).then((response) => response.json())
.then((responseJson) => {
console.log(JSON.stringify(responseJson));
// alert(JSON.stringify(responseJson))
// if (responseJson.status === 'TRUE') {
// AsyncStorage.setItem('auth', responseJson.jwt) //store the token information with exp
// const tokenDetails = jwt_decode(responseJson.jwt);
// console.log(tokenDetails.data)
// AsyncStorage.setItem('roleCount', tokenDetails.data.roleCount)
// // dispatch(setCurrentUser(tokenDetails.data)); //store the user information
// AsyncStorage.setItem('status', tokenDetails.data.empStatus)
// AsyncStorage.setItem('userToken', tokenDetails.data.empId);
// AsyncStorage.setItem('userName', tokenDetails.data.userName);
// AsyncStorage.setItem('emp_role', tokenDetails.data.role);
// AsyncStorage.setItem('cropcode', tokenDetails.data.corp);
// AsyncStorage.setItem('fullName', tokenDetails.data.fullName);
// AsyncStorage.setItem('projectId', tokenDetails.data.projectId);
// this.props.navigation.navigate("MyTask");
// }
if (responseJson.status === 'TRUE') {
if (responseJson.role === "admin" || responseJson.role === "Admin") {
AsyncStorage.setItem('auth', responseJson.jwt) //store the token information with exp
const tokenDetails = jwt_decode(responseJson.jwt);
// console.log(tokenDetails.data)
AsyncStorage.setItem('roleCount', tokenDetails.data.roleCount)
// // dispatch(setCurrentUser(tokenDetails.data)); //store the user information
AsyncStorage.setItem('status', tokenDetails.data.empStatus)
AsyncStorage.setItem('userToken', tokenDetails.data.empId);
AsyncStorage.setItem('userName', tokenDetails.data.userName);
AsyncStorage.setItem('emp_role', tokenDetails.data.role);
AsyncStorage.setItem('cropcode', tokenDetails.data.corp);
AsyncStorage.setItem('fullName', tokenDetails.data.fullName);
AsyncStorage.setItem('projectId', tokenDetails.data.projectId);
this.testNotification();
this.setState({
userGoogleInfo: '',
// loaded: true
})
// this.props.navigation.navigate("AdminReports");
}
else {
AsyncStorage.setItem('auth', responseJson.jwt) //store the token information with exp
const tokenDetails = jwt_decode(responseJson.jwt);
// console.log(tokenDetails.data)
AsyncStorage.setItem('roleCount', tokenDetails.data.roleCount)
// // dispatch(setCurrentUser(tokenDetails.data)); //store the user information
AsyncStorage.setItem('status', tokenDetails.data.empStatus)
AsyncStorage.setItem('userToken', tokenDetails.data.empId);
AsyncStorage.setItem('userName', tokenDetails.data.userName);
AsyncStorage.setItem('emp_role', tokenDetails.data.role);
AsyncStorage.setItem('cropcode', tokenDetails.data.corp);
AsyncStorage.setItem('fullName', tokenDetails.data.fullName);
AsyncStorage.setItem('projectId', tokenDetails.data.projectId);
this.testNotification1()
this.setState({
userGoogleInfo: '',
// loaded: true
})
// this.props.navigation.navigate("MyTask");
}
}
else if (responseJson.status === "False") {
AsyncStorage.setItem('roleCount', tokenDetails.data.roleCount)
AsyncStorage.setItem('empId', tokenDetails.data.empId) //store the token information with exp
AsyncStorage.setItem('user', tokenDetails.data.username) //store the token information with exp
// dispatch(setCurrentUser(response)); //store the user information
// setRedirect(true)
console.warn(responseJsone)
Alert('warning', responseJsone)
// store.dispatch(isLoaded());
}
else {
console.log(JSON.stringify(responseJson));
alert(JSON.stringify(responseJson.message))
// alert("Login Details are Invalid")
log("Warn", "UserName and Password is not entered correctly");
}
}).catch((error) => {
console.error(error);
log("Error", "Login Error");
});
}
//User or Admin Login
onSignIn() {
// alert("hello")
......@@ -331,60 +500,60 @@ export default class Login extends Component {
// if (userId === null) {
// alert("Relogin Again")
// this.setState({
// username: '',
// password: ''
// })
// }
// else {
NetInfo.fetch().then(state => {
if (state.type == "none") {
console.log(state.type);
log("Warn", "No internet connection");
Snackbar.show({
title: 'No Internet Connection',
backgroundColor: 'red',
duration: Snackbar.LENGTH_LONG,
});
}
NetInfo.fetch().then(state => {
if (state.type == "none") {
console.log(state.type);
log("Warn", "No internet connection");
Snackbar.show({
title: 'No Internet Connection',
backgroundColor: 'red',
duration: Snackbar.LENGTH_LONG,
});
}
else {
fetch(API + 'device_store.php', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
device_id: userId,
empId: empId,
action: "store_device",
else {
fetch(API + 'device_store.php', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
device_id: userId,
empId: empId,
action: "store_device",
})
}).then((response) => response.json())
.then((responseJson) => {
// alert(JSON.stringify(responseJson));
console.log(JSON.stringify(responseJson));
if (responseJson.status === 'True') {
this.props.navigation.navigate("UserDashboard")
// alert("Sucess")
console.log("done")
// this.props.navigation.goBack();
this.setState({ open: false })
}
}).catch((error) => {
console.error(error);
log("Error", "addSubTask error");
});
})
}).then((response) => response.json())
.then((responseJson) => {
// alert(JSON.stringify(responseJson));
console.log(JSON.stringify(responseJson));
if (responseJson.status === 'True') {
this.props.navigation.navigate("UserDashboard")
// alert("Sucess")
console.log("done")
// this.props.navigation.goBack();
this.setState({ open: false })
}
}).catch((error) => {
console.error(error);
log("Error", "addSubTask error");
});
}
// }
});
}
// }
});
// }
});
......@@ -553,10 +722,29 @@ export default class Login extends Component {
<TouchableOpacity onPress={() => this.props.navigation.navigate("ReportBug")} style={[styles.buttonContainerforgot,]}>
<Text style={styles.signUpTextforgot}>Support</Text>
<Icon name="handshake-o" size={20} style={{ color: '#fff',}} />
<Icon name="handshake-o" size={20} style={{ color: '#fff', }} />
</TouchableOpacity>
<View >
{/* <Text style={{ color: 'white' }} onPress={()=>this.props.navigation.navigate('RegisterUser')}> New User ? </Text> */}
<View style={[styles.googlesigninstyles]}>
<GoogleSigninButton
style={{ width: 222, height: 48 }}
size={GoogleSigninButton.Size.Wide}
color={GoogleSigninButton.Color.Dark}
onPress={this.signIn}
/>
{/* {this.state.loaded ?
<View>
<Text>{this.state.userGoogleInfo.user.name}</Text>
<Text>{this.state.userGoogleInfo.user.email}</Text>
<Image
style={{ width: 100, height: 100 }}
source={{ uri: this.state.userGoogleInfo.user.photo }}
/>
</View>
: <Text>Not SignedIn</Text>} */}
</View>
</View>
......@@ -655,6 +843,16 @@ const styles = StyleSheet.create({
borderRadius: 30,
flexDirection: 'row',
},
googlesigninstyles: {
height: 45,
justifyContent: 'center',
alignItems: 'center',
marginBottom: 10,
width: 290,
borderRadius: 30,
flexDirection: 'column',
},
signupButton: {
backgroundColor: "#ffffff",
......
......@@ -625,7 +625,8 @@ export default class UserDashboardPersonalTodo extends React.Component {
if (responseJson.status === 'True') {
// this.refs.toast.showCenter('Epic Squad is Deactivated', Toast.Duration.long, Toast.Position.center);
console.log("done")
alert(JSON.stringify(responseJson.message));
// alert(JSON.stringify(responseJson.message));
alert("Sucessfully Deleted")
//this.refs.toast.showBottom('Employee is Deleted');
this.getModules();
this.setState({ open: false })
......
......@@ -739,6 +739,7 @@ export default class UserGroupChat extends Component {
});
this.getGroupDetails();
// this.onRefresh();
// alert("Project Changed Successfully")
......@@ -1194,6 +1195,7 @@ export default class UserGroupChat extends Component {
componentWillReceiveProps(nextProps) {
this.userApprovedProjects();
this.getGroupDetails()
}
//userApprovedProjects getting
userApprovedProjects() {
......@@ -1245,6 +1247,8 @@ export default class UserGroupChat extends Component {
}, function () {
});
// this.onRefresh();
this.getGroupDetails();
// console.warn(responseJson.taskStatus);
// this.arrayholder = responseJson.data;
} else {
......@@ -1254,7 +1258,7 @@ export default class UserGroupChat extends Component {
dataSource: [],
})
Snackbar.show({
title: 'No UserApproved Projects',
title: 'No Groups Found',
backgroundColor: '#3BB9FF',
duration: Snackbar.LENGTH_LONG,
});
......
......@@ -221,7 +221,7 @@ isValid() {
else if (steps_for_bug.length === 0) {
log("Warn", "Steps should not be empty");
// alert("Enter Steps of Bugs");
alert("Enter Steps of Bugs");
}
// else if (mobile.length === 0) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment