Commit 001bba5b authored by Indika NK's avatar Indika NK

Login register part 2 added

parent 1404098a
import 'package:cloud_firestore/cloud_firestore.dart';
class dataService{
String email;
String name;
String address;
String NIC;
String mobile;
String homeNumber;
String awarenessLevel;
final String uid;
dataService({this.uid});
final CollectionReference userCollection = FirebaseFirestore.instance.collection('users');
// // getting user data to update
Future updateUserData(
String email,
String name,
String address,
String NIC,
String mobile,
String homeNumber,
String awarenessLevel,) async
{
return await userCollection.doc(uid).setData({
'email':email,
'Name':name,
'Address':address,
'NIC':NIC,
'mobile':mobile,
'Home phone':homeNumber,
'awarenessLevel':awarenessLevel
}).whenComplete(() => print("Data successfully Added"));
}
// DocumentReference documentReference =
// Firestore.instance.collection("users").document(name);
//
// Map<String, dynamic> userdata = {
// 'email':email,
// 'Name':name,
// 'Address':address,
// 'NIC':NIC,
// 'mobile':mobile,
// 'Home_phone':homeNumber,
// 'awarenessLevel':awarenessLevel
// };
//
// documentReference.setData(user).whenComplete(() {
// print("$userName created");
// });
// }
// }
// class AuthService {
//
// //uid
// final String uid;
// AuthService({this.uid});
//
// //firestore refference
// final CollectionReference userCollection = FirebaseFirestore.instance.collection('users');
//
//
// // getting user data to update
// Future updateUserData(
// String email,
// String name,
// String address,
// String NIC,
// String mobile,
// String homeNumber,
// String awarenessLevel,) async
// {
// print("CollectionReference"+userCollection.toString());
//
// return await userCollection.doc(uid).set({
// 'email':email,
// 'Name':name,
// 'Address':address,
// 'NIC':NIC,
// 'mobile':mobile,
// 'Home_phone':homeNumber,
// 'awarenessLevel':awarenessLevel
// });
// }
//
//
}
\ No newline at end of file
import 'package:covidefender/AuthConfigs/AuthConfig.dart';
import 'package:covidefender/home_screen.dart'; import 'package:covidefender/home_screen.dart';
import 'package:firebase_auth/firebase_auth.dart'; import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
...@@ -44,6 +45,7 @@ class _RegisterState extends State<Register> { ...@@ -44,6 +45,7 @@ class _RegisterState extends State<Register> {
signUp() async { signUp() async {
//if validate ok then save current state //if validate ok then save current state
print("******* Executing Signup ********");
if (_formKey.currentState.validate()) _formKey.currentState.save(); if (_formKey.currentState.validate()) _formKey.currentState.save();
try { try {
// create user with email and password // create user with email and password
...@@ -51,6 +53,17 @@ class _RegisterState extends State<Register> { ...@@ -51,6 +53,17 @@ class _RegisterState extends State<Register> {
.createUserWithEmailAndPassword(email: _email, password: _password); .createUserWithEmailAndPassword(email: _email, password: _password);
FirebaseUser user = result.user; FirebaseUser user = result.user;
print("******* Executing updateUserdata ********");
await dataService(uid: user.uid).updateUserData(
_email,
_name,
_address,
_NIC,
_phoneNumber,
_HomeNumber,
_awarenessLevel
);
print("Firebase user"+user.toString()); print("Firebase user"+user.toString());
// await AuthService(uid:user.uid).updateUserData("email", "name", "address", "NIC", "mobile", "homeNumber", "awarenessLevel"); // await AuthService(uid:user.uid).updateUserData("email", "name", "address", "NIC", "mobile", "homeNumber", "awarenessLevel");
......
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