pull/603/head
Halil ibrahim Kalkan 6 years ago
commit 124173351d

@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Volo.Abp.Identity.Settings;
using Volo.Abp.Users;
namespace Volo.Abp.Identity
@ -29,13 +28,30 @@ namespace Volo.Abp.Identity
{
var user = await _userManager.GetByIdAsync(CurrentUser.GetId());
var isUsernameUpdateEnabled = string.Equals(await (SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled)),
"true", StringComparison.OrdinalIgnoreCase);
if (isUsernameUpdateEnabled)
{
(await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
}
var isEmailUpdateEnabled = !string.Equals(await (SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsEmailUpdateEnabled)),
"true", StringComparison.OrdinalIgnoreCase);
if (isEmailUpdateEnabled)
{
(await _userManager.SetEmailAsync(user, input.Email)).CheckErrors();
}
(await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
user.Name = input.Name;
user.Surname = input.Surname;
(await _userManager.UpdateAsync(user)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityUser, ProfileDto>(user);

@ -2,11 +2,19 @@
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@using Volo.Abp.Identity.Localization
@using Volo.Abp.Identity.Settings
@using Volo.Abp.Identity.Web.Pages.Identity.Shared
@using Volo.Abp.Settings
@model PersonalSettingsModal
@inject IHtmlLocalizer<IdentityResource> L
@inject ISettingManager SettingManager
@{
Layout = null;
var isUserNameUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsUserNameUpdateEnabled), "true",
StringComparison.OrdinalIgnoreCase);
var isEmailUpdateEnabled = string.Equals(await SettingManager.GetOrNullAsync(IdentitySettingNames.User.IsEmailUpdateEnabled), "true",
StringComparison.OrdinalIgnoreCase);
}
<form asp-page="/Identity/Shared/PersonalSettingsModal">
@ -14,7 +22,7 @@
<abp-modal-header title="@L["PersonalInfo"].Value"></abp-modal-header>
<abp-modal-body>
<abp-input asp-for="PersonalSettingsInfoModel.UserName" readonly="Model.IsUsernameUpdateDisabled" />
<abp-input asp-for="PersonalSettingsInfoModel.UserName" readonly="!isUserNameUpdateEnabled" />
<abp-row>
<abp-column size-md="_6">
@ -25,7 +33,7 @@
</abp-column>
</abp-row>
<abp-input asp-for="PersonalSettingsInfoModel.Email" readonly="Model.IsEmailUpdateDisabled" />
<abp-input asp-for="PersonalSettingsInfoModel.Email" readonly="!isEmailUpdateEnabled" />
<abp-input asp-for="PersonalSettingsInfoModel.PhoneNumber" />

@ -1,10 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Identity.Settings;
using Volo.Abp.Settings;
namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
{
@ -13,18 +10,6 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
[BindProperty]
public PersonalSettingsInfoModel PersonalSettingsInfoModel { get; set; }
[BindProperty]
public PersonalSettingsInfoModel PersonalSettingsInfoModel2 { get; set; }
public bool IsUsernameUpdateDisabled => !string.Equals(
SettingManager.GetOrNull(IdentitySettingNames.User.IsUserNameUpdateEnabled), "true",
StringComparison.OrdinalIgnoreCase);
public bool IsEmailUpdateDisabled => !string.Equals(
SettingManager.GetOrNull(IdentitySettingNames.User.IsEmailUpdateEnabled), "true",
StringComparison.OrdinalIgnoreCase);
private readonly IProfileAppService _profileAppService;
public PersonalSettingsModal(IProfileAppService profileAppService)
@ -45,24 +30,6 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
var updateDto = ObjectMapper.Map<PersonalSettingsInfoModel, UpdateProfileDto>(PersonalSettingsInfoModel);
ProfileDto user = null;
if (IsUsernameUpdateDisabled )
{
user = await _profileAppService.GetAsync();
updateDto.UserName = user.UserName;
}
if (IsEmailUpdateDisabled)
{
if (user == null)
{
user = await _profileAppService.GetAsync();
}
updateDto.Email = user.Email;
}
await _profileAppService.UpdateAsync(updateDto);
return NoContent();

Loading…
Cancel
Save