Null checks and property uses

This commit is contained in:
Scott Brady
2020-05-04 18:32:57 +01:00
parent 57ec84cb47
commit 04e9140486
2 changed files with 6 additions and 6 deletions
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Specialized;
using System.Net.Http;
using System.Text;
@@ -65,6 +65,9 @@ namespace Umbraco.Web.Install.InstallSteps
//To change the password here we actually need to reset it since we don't have an old one to use to change
var resetToken = await userManager.GeneratePasswordResetTokenAsync(membershipUser);
if (string.IsNullOrWhiteSpace(resetToken))
throw new InvalidOperationException("Could not reset password: unable to generate internal reset token");
var resetResult = await userManager.ChangePasswordWithResetAsync(membershipUser.Id, resetToken, user.Password.Trim());
if (!resetResult.Succeeded)
{
@@ -78,17 +78,14 @@ namespace Umbraco.Web.Security
/// <returns></returns>
public static async Task<ExternalLoginInfo> GetExternalLoginInfoAsync(this IAuthenticationManager manager, string authenticationType)
{
if (manager == null)
{
throw new ArgumentNullException("manager");
}
if (manager == null) throw new ArgumentNullException(nameof(manager));
return GetExternalLoginInfo(await manager.AuthenticateAsync(authenticationType));
}
public static IEnumerable<AuthenticationDescription> GetExternalAuthenticationTypes(this IAuthenticationManager manager)
{
if (manager == null) throw new ArgumentNullException(nameof(manager));
return manager.GetAuthenticationTypes(d => d.Properties != null && d.Properties.ContainsKey("Caption"));
return manager.GetAuthenticationTypes(d => d.Properties != null && d.Caption != null);
}
public static ClaimsIdentity CreateTwoFactorRememberBrowserIdentity(this IAuthenticationManager manager, string userId)