Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2021-035-CoviDefender
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2021-035
2021-035-CoviDefender
Commits
001bba5b
Commit
001bba5b
authored
Aug 17, 2021
by
Indika NK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Login register part 2 added
parent
1404098a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
117 additions
and
0 deletions
+117
-0
lib/AuthConfigs/AuthConfig.dart
lib/AuthConfigs/AuthConfig.dart
+104
-0
lib/AuthConfigs/Register.dart
lib/AuthConfigs/Register.dart
+13
-0
No files found.
lib/AuthConfigs/AuthConfig.dart
0 → 100644
View file @
001bba5b
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
lib/AuthConfigs/Register.dart
View file @
001bba5b
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");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment