Add reusable two-factor verification for login and money operations (#32)
This commit is contained in:
1 parent
b7a58b1a87
commit
fb40f860d2
41 files changed
+2439
-43
No files matched your search
@@ -31,6 +31,7 @@ class SxchngeApp extends StatefulWidget {
|
||||
this.identityService,
|
||||
this.limitsService,
|
||||
this.walletService,
|
||||
this.twoFactorService,
|
||||
this.photoService = const FilePhotoService(),
|
||||
this.loginService = const DummyLoginService(),
|
||||
this.signupService = const DummySignupService(),
|
||||
@@ -41,6 +42,7 @@ class SxchngeApp extends StatefulWidget {
|
||||
final IdentityService? identityService;
|
||||
final LimitsService? limitsService;
|
||||
final WalletService? walletService;
|
||||
final TwoFactorService? twoFactorService;
|
||||
final PhotoService photoService;
|
||||
final LoginService loginService;
|
||||
final SignupService signupService;
|
||||
@@ -54,11 +56,21 @@ class _SxchngeAppState extends State<SxchngeApp> {
|
||||
late final _locale = widget.localeProvider ?? LocaleProvider();
|
||||
|
||||
late final _analytics = widget.analyticsService ?? DummyAnalyticsService();
|
||||
late final _factors = widget.twoFactorService ?? DummyTwoFactorService();
|
||||
late final _security = SecurityProvider(_factors, _analytics);
|
||||
late final _identity = widget.identityService ?? DummyIdentityService();
|
||||
late final _walletService =
|
||||
widget.walletService ??
|
||||
DummyWalletService(_identity, initialLocale: _locale.locale.languageCode);
|
||||
late final _wallet = WalletProvider(_walletService, _analytics);
|
||||
DummyWalletService(
|
||||
_identity,
|
||||
initialLocale: _locale.locale.languageCode,
|
||||
factors: _factors,
|
||||
);
|
||||
late final _wallet = WalletProvider(
|
||||
_walletService,
|
||||
_analytics,
|
||||
factors: _factors,
|
||||
);
|
||||
late final _limits =
|
||||
widget.limitsService ??
|
||||
(_walletService is DummyWalletService
|
||||
@@ -67,7 +79,7 @@ class _SxchngeAppState extends State<SxchngeApp> {
|
||||
late final _journeys = JourneyRecorder(_analytics);
|
||||
late final _services = InstrumentedAuthServices(
|
||||
recorder: _journeys,
|
||||
loginService: widget.loginService,
|
||||
loginService: GuardedLoginService(widget.loginService, _factors),
|
||||
signupService: widget.signupService,
|
||||
verificationService: widget.verificationService,
|
||||
);
|
||||
@@ -83,7 +95,7 @@ class _SxchngeAppState extends State<SxchngeApp> {
|
||||
|
||||
void _routeChanged() {
|
||||
final path = _router.routeInformationProvider.value.uri.path;
|
||||
if (path == '/' && _previousPath != '/') {
|
||||
if (path == '/' && _previousPath != '/' && _previousPath != '/two-factor') {
|
||||
_journeys.abandon(JourneyExit.navigation);
|
||||
}
|
||||
_previousPath = path;
|
||||
@@ -95,6 +107,7 @@ class _SxchngeAppState extends State<SxchngeApp> {
|
||||
_router.dispose();
|
||||
_journeys.dispose();
|
||||
_wallet.dispose();
|
||||
_security.dispose();
|
||||
_locale.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -103,6 +116,8 @@ class _SxchngeAppState extends State<SxchngeApp> {
|
||||
Widget build(BuildContext context) => MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider.value(value: _wallet),
|
||||
ChangeNotifierProvider.value(value: _security),
|
||||
Provider<TwoFactorService>.value(value: _factors),
|
||||
Provider<JourneyRecorder>.value(value: _journeys),
|
||||
Provider<AnalyticsService>.value(value: _analytics),
|
||||
Provider<IdentityService>.value(value: _identity),
|
||||
|
||||
Reference in new issue
Block a user