Adds native ability to be able to fallback to default password checking if specifying a custom IBackOfficeUserPasswordChecker

This commit is contained in:
Shannon
2015-10-26 14:51:19 +01:00
parent 96c087d00f
commit 9b054eaa47
4 changed files with 23 additions and 5 deletions

View File

@@ -201,12 +201,17 @@ namespace Umbraco.Core.Security
/// </remarks>
public async override Task<bool> CheckPasswordAsync(T user, string password)
{
if (BackOfficeUserPasswordChecker == null)
if (BackOfficeUserPasswordChecker != null)
{
//use the default behavior
return await base.CheckPasswordAsync(user, password);
var result = await BackOfficeUserPasswordChecker.CheckPasswordAsync(user, password);
//if the result indicates to not fallback to the default, then return true if the credentials are valid
if (result != BackOfficeUserPasswordCheckerResult.FallbackToDefaultChecker)
{
return result == BackOfficeUserPasswordCheckerResult.ValidCredentials;
}
}
return await BackOfficeUserPasswordChecker.CheckPasswordAsync(user, password);
//use the default behavior
return await base.CheckPasswordAsync(user, password);
}
/// <summary>