Skip to content

Commit

Permalink
send email verification on signup
Browse files Browse the repository at this point in the history
  • Loading branch information
IoanaAlexandru committed Mar 19, 2020
1 parent 9d042b0 commit 55cb39c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
15 changes: 11 additions & 4 deletions lib/authentication/service/auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extension DatabaseUser on User {
}

class AuthProvider with ChangeNotifier {
FirebaseUser firebaseUser; // TODO: Make this private
FirebaseUser firebaseUser; // TODO: Make this private
StreamSubscription userAuthSub;

AuthProvider() {
Expand Down Expand Up @@ -109,8 +109,10 @@ class AuthProvider with ChangeNotifier {
if (isAnonymous) {
return null;
}
DocumentSnapshot snapshot =
await Firestore.instance.collection('users').document(firebaseUser.uid).get();
DocumentSnapshot snapshot = await Firestore.instance
.collection('users')
.document(firebaseUser.uid)
.get();
return DatabaseUser.fromSnap(snapshot);
}

Expand Down Expand Up @@ -290,7 +292,12 @@ class AuthProvider with ChangeNotifier {
Firestore.instance.collection('users').document(user.uid);
ref.setData(user.toData());

AppToast.show(S.of(context).messageAccountCreated);
// Send verification e-mail
await firebaseUser.sendEmailVerification();

AppToast.show(S.of(context).messageAccountCreated +
' ' +
S.of(context).messageCheckEmailVerification);
return true;
} catch (e) {
_errorHandler(e, context);
Expand Down
1 change: 1 addition & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MessageLookup extends MessageLookupByLibrary {
"labelLastName" : MessageLookupByLibrary.simpleMessage("Last name"),
"labelPassword" : MessageLookupByLibrary.simpleMessage("Password"),
"messageAccountCreated" : MessageLookupByLibrary.simpleMessage("Account created successfully."),
"messageCheckEmailVerification" : MessageLookupByLibrary.simpleMessage("Please check your email for account verification."),
"messageNewUser" : MessageLookupByLibrary.simpleMessage("New user?"),
"messageResetPassword" : MessageLookupByLibrary.simpleMessage("Enter your e-mai in order to receive instructions on how to reset your password."),
"messageUnderConstruction" : MessageLookupByLibrary.simpleMessage("Under construction"),
Expand Down
1 change: 1 addition & 0 deletions lib/generated/intl/messages_ro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class MessageLookup extends MessageLookupByLibrary {
"labelLastName" : MessageLookupByLibrary.simpleMessage("Nume"),
"labelPassword" : MessageLookupByLibrary.simpleMessage("Parolă"),
"messageAccountCreated" : MessageLookupByLibrary.simpleMessage("Contul a fost creat cu succes."),
"messageCheckEmailVerification" : MessageLookupByLibrary.simpleMessage("Verificați-vă mail-ul pentru confirmarea contului."),
"messageNewUser" : MessageLookupByLibrary.simpleMessage("Utilizator nou?"),
"messageResetPassword" : MessageLookupByLibrary.simpleMessage("Introduceți mail-ul pentru a primi instrucțiuni de resetare a parolei."),
"messageUnderConstruction" : MessageLookupByLibrary.simpleMessage("În construcție"),
Expand Down
13 changes: 11 additions & 2 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"messageWelcomeName": "Welcome, {name}!",
"messageNewUser": "New user?",
"messageAccountCreated": "Account created successfully.",
"messageCheckEmailVerification": "Please check your email for account verification.",
"messageResetPassword": "Enter your e-mai in order to receive instructions on how to reset your password.",
"messageUnderConstruction": "Under construction",

Expand Down
1 change: 1 addition & 0 deletions lib/l10n/intl_ro.arb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"messageWelcomeName": "Bine ai venit, {name}!",
"messageNewUser":"Utilizator nou?",
"messageAccountCreated": "Contul a fost creat cu succes.",
"messageCheckEmailVerification": "Verificați-vă mail-ul pentru confirmarea contului.",
"messageResetPassword": "Introduceți mail-ul pentru a primi instrucțiuni de resetare a parolei.",
"messageUnderConstruction": "În construcție",

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: A mobile application for students at ACS UPB.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.3.10+2
version: 0.3.11+1

environment:
sdk: ">=2.6.0 <3.0.0"
Expand Down

0 comments on commit 55cb39c

Please sign in to comment.