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..6f26437 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.)) + /// PlatformException(AUTH_ERROR, Authentication failed, access_denied;AADB2C90118: The user has forgotten their password. + var detailsInLowerCase = e.details.toString().toLowerCase(); + if (e.details != null && + (detailsInLowerCase.contains('msalerrordomain error -50000') || + detailsInLowerCase.contains('aadb2c90118'))) { + return MsalForgotPasswordException(); + } else { + return MsalException("Authentication error"); + } } }