Browse Source

Refactor pull/4975

pull/4975/head
Yunus Emre Kalkan 6 years ago
parent
commit
36fa40e61e
  1. 2
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs
  2. 2
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/ProfileDto.cs
  3. 4
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModuleAutoMapperProfile.cs
  4. 7
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs

2
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Manage.cshtml.cs

@ -29,7 +29,7 @@ namespace Volo.Abp.Account.Web.Pages.Account
PersonalSettingsInfoModel = ObjectMapper.Map<ProfileDto, PersonalSettingsInfoModel>(user); PersonalSettingsInfoModel = ObjectMapper.Map<ProfileDto, PersonalSettingsInfoModel>(user);
DisablePasswordChange = user.IsExternalLoggedIn; DisablePasswordChange = user.IsExternal;
HideOldPasswordInput = !user.HasPassword; HideOldPasswordInput = !user.HasPassword;
return Page(); return Page();

2
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/ProfileDto.cs

@ -14,7 +14,7 @@ namespace Volo.Abp.Identity
public string PhoneNumber { get; set; } public string PhoneNumber { get; set; }
public bool IsExternalLoggedIn { get; set; } public bool IsExternal { get; set; }
public bool HasPassword { get; set; } public bool HasPassword { get; set; }
} }

4
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModuleAutoMapperProfile.cs

@ -14,8 +14,8 @@ namespace Volo.Abp.Identity
.MapExtraProperties(); .MapExtraProperties();
CreateMap<IdentityUser, ProfileDto>() CreateMap<IdentityUser, ProfileDto>()
.Ignore(x=>x.IsExternalLoggedIn) .ForMember(dest => dest.HasPassword,
.Ignore(x=>x.HasPassword) op => op.MapFrom(src => src.PasswordHash != null))
.MapExtraProperties(); .MapExtraProperties();
} }
} }

7
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs

@ -23,11 +23,7 @@ namespace Volo.Abp.Identity
{ {
var currentUser = await UserManager.GetByIdAsync(CurrentUser.GetId()); var currentUser = await UserManager.GetByIdAsync(CurrentUser.GetId());
var profile = ObjectMapper.Map<IdentityUser, ProfileDto>(currentUser); return ObjectMapper.Map<IdentityUser, ProfileDto>(currentUser);
profile.IsExternalLoggedIn = currentUser.IsExternal;
profile.HasPassword = currentUser.PasswordHash != null;
return profile;
} }
public virtual async Task<ProfileDto> UpdateAsync(UpdateProfileDto input) public virtual async Task<ProfileDto> UpdateAsync(UpdateProfileDto input)
@ -69,7 +65,6 @@ namespace Volo.Abp.Identity
if (currentUser.PasswordHash == null) if (currentUser.PasswordHash == null)
{ {
(await UserManager.RemovePasswordAsync(currentUser)).CheckErrors();
(await UserManager.AddPasswordAsync(currentUser, input.NewPassword)).CheckErrors(); (await UserManager.AddPasswordAsync(currentUser, input.NewPassword)).CheckErrors();
return; return;

Loading…
Cancel
Save