From 7b258f889d9872181638182eed3e902b7f3f48d1 Mon Sep 17 00:00:00 2001 From: Roy Donasco Date: Fri, 24 Jul 2020 19:57:08 +0800 Subject: [PATCH 1/2] added support to throw forgot password exception --- lib/src/msal_exception.dart | 4 ++++ lib/src/public_client_application.dart | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/src/msal_exception.dart b/lib/src/msal_exception.dart index e7d790c..59c1c00 100644 --- a/lib/src/msal_exception.dart +++ b/lib/src/msal_exception.dart @@ -37,3 +37,7 @@ class MsalUninitializedException extends MsalException { : super( "Client not initialized. Client must be initialized before attempting to use"); } + +class MsalForgotPasswordException extends MsalException { + MsalForgotPasswordException() : super("User forgot password"); +} diff --git a/lib/src/public_client_application.dart b/lib/src/public_client_application.dart index 6e235af..2dc8599 100644 --- a/lib/src/public_client_application.dart +++ b/lib/src/public_client_application.dart @@ -1,5 +1,7 @@ import 'dart:async'; + import 'package:flutter/services.dart'; + import 'msal_exception.dart'; /// Represents a PublicClientApplication used to authenticate using the implicit flow @@ -88,7 +90,17 @@ class PublicClientApplication { return MsalInitializationException(); case "AUTH_ERROR": default: - return MsalException("Authentication error"); + + /// PlatformException(AUTH_ERROR, Authentication error, The operation couldn’t be completed. (MSALErrorDomain error -50000.)) + if (e.details != null && + e.details + .toString() + .toLowerCase() + .contains('msalerrordomain error -50000')) { + return MsalForgotPasswordException(); + } else { + return MsalException("Authentication error"); + } } } From 04eb0705004f09a0973decbb555efea13e2db7d2 Mon Sep 17 00:00:00 2001 From: Roy Donasco Date: Mon, 27 Jul 2020 11:57:27 +0800 Subject: [PATCH 2/2] Added error returned on android device to handle forgot password --- lib/src/public_client_application.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/src/public_client_application.dart b/lib/src/public_client_application.dart index 2dc8599..6f26437 100644 --- a/lib/src/public_client_application.dart +++ b/lib/src/public_client_application.dart @@ -92,11 +92,11 @@ class PublicClientApplication { default: /// PlatformException(AUTH_ERROR, Authentication error, The operation couldn’t be completed. (MSALErrorDomain error -50000.)) + /// PlatformException(AUTH_ERROR, Authentication failed, access_denied;AADB2C90118: The user has forgotten their password. + var detailsInLowerCase = e.details.toString().toLowerCase(); if (e.details != null && - e.details - .toString() - .toLowerCase() - .contains('msalerrordomain error -50000')) { + (detailsInLowerCase.contains('msalerrordomain error -50000') || + detailsInLowerCase.contains('aadb2c90118'))) { return MsalForgotPasswordException(); } else { return MsalException("Authentication error");