Skip to content

Commit

Permalink
call reload before checking is user account is validates
Browse files Browse the repository at this point in the history
FirebaseAuth.instance.currentUser() returns cached data, so reload()
needs to be called if you want updated data
  • Loading branch information
IoanaAlexandru committed Mar 19, 2020
1 parent 7d49a3b commit 508a8fd
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 64 deletions.
1 change: 1 addition & 0 deletions lib/authentication/service/auth_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class AuthProvider with ChangeNotifier {

/// Check the network to see if there is a user authenticated
Future<bool> get isVerifiedFromService async {
firebaseUser.reload();
firebaseUser = await FirebaseAuth.instance.currentUser();
return firebaseUser.isEmailVerified;
}
Expand Down
1 change: 0 additions & 1 deletion lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class MessageLookup extends MessageLookupByLibrary {
"messageEmailNotVerified" : MessageLookupByLibrary.simpleMessage("Account is not verified."),
"messageNewUser" : MessageLookupByLibrary.simpleMessage("New user?"),
"messageResetPassword" : MessageLookupByLibrary.simpleMessage("Enter your e-mai in order to receive instructions on how to reset your password."),
"messageSignInAfterVerification" : MessageLookupByLibrary.simpleMessage("You may need to sign in again after verification."),
"messageUnderConstruction" : MessageLookupByLibrary.simpleMessage("Under construction"),
"messageWelcomeName" : m2,
"messageWelcomeSimple" : MessageLookupByLibrary.simpleMessage("Welcome!"),
Expand Down
1 change: 0 additions & 1 deletion lib/generated/intl/messages_ro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class MessageLookup extends MessageLookupByLibrary {
"messageEmailNotVerified" : MessageLookupByLibrary.simpleMessage("Contul nu este verificat."),
"messageNewUser" : MessageLookupByLibrary.simpleMessage("Utilizator nou?"),
"messageResetPassword" : MessageLookupByLibrary.simpleMessage("Introduceți mail-ul pentru a primi instrucțiuni de resetare a parolei."),
"messageSignInAfterVerification" : MessageLookupByLibrary.simpleMessage("Va trebui să vă conectați din nou după verificare."),
"messageUnderConstruction" : MessageLookupByLibrary.simpleMessage("În construcție"),
"messageWelcomeName" : m2,
"messageWelcomeSimple" : MessageLookupByLibrary.simpleMessage("Bine ai venit!"),
Expand Down
9 changes: 0 additions & 9 deletions lib/generated/l10n.dart

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

1 change: 0 additions & 1 deletion lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"messageEmailNotVerified": "Account is not verified.",
"messageAccountCreated": "Account created successfully.",
"messageCheckEmailVerification": "Please check your email for account verification.",
"messageSignInAfterVerification": "You may need to sign in again after verification.",
"messageResetPassword": "Enter your e-mai in order to receive instructions on how to reset your password.",
"messageUnderConstruction": "Under construction",

Expand Down
1 change: 0 additions & 1 deletion lib/l10n/intl_ro.arb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"messageEmailNotVerified": "Contul nu este verificat.",
"messageAccountCreated": "Contul a fost creat cu succes.",
"messageCheckEmailVerification": "Verificați-vă mail-ul pentru confirmarea contului.",
"messageSignInAfterVerification": "Va trebui să vă conectați din nou după verificare.",
"messageResetPassword": "Introduceți mail-ul pentru a primi instrucțiuni de resetare a parolei.",
"messageUnderConstruction": "În construcție",

Expand Down
82 changes: 32 additions & 50 deletions lib/pages/profile/profile_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'package:acs_upb_mobile/authentication/service/auth_provider.dart';
import 'package:acs_upb_mobile/generated/l10n.dart';
import 'package:acs_upb_mobile/navigation/routes.dart';
import 'package:acs_upb_mobile/widgets/scaffold.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand All @@ -24,56 +23,39 @@ class ProfilePage extends StatelessWidget {
}
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: <Widget>[
ConstrainedBox(
constraints:
BoxConstraints(maxWidth: MediaQuery.of(context).size.width),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.error_outline,
size: Theme.of(context).textTheme.subtitle2.fontSize,
),
SizedBox(width: 4),
Text(
S.of(context).messageEmailNotVerified,
style: Theme.of(context)
.textTheme
.subtitle2
.copyWith(fontWeight: FontWeight.w400),
maxLines: 1,
),
InkWell(
onTap: () {
authProvider.sendEmailVerification(context: context);
},
child: Text(
' ' + S.of(context).actionSendVerificationAgain,
style: Theme.of(context)
.accentTextTheme
.subtitle2
.copyWith(fontWeight: FontWeight.w500),
),
),
],
child: ConstrainedBox(
constraints:
BoxConstraints(maxWidth: MediaQuery.of(context).size.width),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.error_outline,
size: Theme.of(context).textTheme.subtitle2.fontSize,
),
),
SizedBox(height: 4),
AutoSizeText(
S.of(context).messageSignInAfterVerification,
style: Theme.of(context)
.textTheme
.subtitle2
.copyWith(fontWeight: FontWeight.w400)
.apply(
fontSizeDelta: -2, color: Theme.of(context).hintColor),
maxLines: 1,
overflow: TextOverflow.visible,
minFontSize: 0,
)
],
SizedBox(width: 4),
Text(
S.of(context).messageEmailNotVerified,
style: Theme.of(context)
.textTheme
.subtitle2
.copyWith(fontWeight: FontWeight.w400),
maxLines: 1,
),
InkWell(
onTap: () {
authProvider.sendEmailVerification(context: context);
},
child: Text(
' ' + S.of(context).actionSendVerificationAgain,
style: Theme.of(context)
.accentTextTheme
.subtitle2
.copyWith(fontWeight: FontWeight.w500),
),
),
],
),
),
);
},
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.13+1
version: 0.3.14+1

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

0 comments on commit 508a8fd

Please sign in to comment.