Browse Source

Merge branch 'master' of https://github.com/volosoft/abp

pull/603/head
Halil ibrahim Kalkan 8 years ago
parent
commit
124173351d
  1. 24
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/ProfileAppService.cs
  2. 12
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml
  3. 35
      modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml.cs

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

@ -1,9 +1,8 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Volo.Abp.Identity.Settings;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace Volo.Abp.Identity namespace Volo.Abp.Identity
@ -29,13 +28,30 @@ namespace Volo.Abp.Identity
{ {
var user = await _userManager.GetByIdAsync(CurrentUser.GetId()); var user = await _userManager.GetByIdAsync(CurrentUser.GetId());
(await _userManager.SetUserNameAsync(user, input.UserName)).CheckErrors();
(await _userManager.SetEmailAsync(user, input.Email)).CheckErrors(); 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(); (await _userManager.SetPhoneNumberAsync(user, input.PhoneNumber)).CheckErrors();
user.Name = input.Name; user.Name = input.Name;
user.Surname = input.Surname; user.Surname = input.Surname;
(await _userManager.UpdateAsync(user)).CheckErrors(); (await _userManager.UpdateAsync(user)).CheckErrors();
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
return ObjectMapper.Map<IdentityUser, ProfileDto>(user); return ObjectMapper.Map<IdentityUser, ProfileDto>(user);

12
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml

@ -2,11 +2,19 @@
@using Microsoft.AspNetCore.Mvc.Localization @using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal @using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@using Volo.Abp.Identity.Localization @using Volo.Abp.Identity.Localization
@using Volo.Abp.Identity.Settings
@using Volo.Abp.Identity.Web.Pages.Identity.Shared @using Volo.Abp.Identity.Web.Pages.Identity.Shared
@using Volo.Abp.Settings
@model PersonalSettingsModal @model PersonalSettingsModal
@inject IHtmlLocalizer<IdentityResource> L @inject IHtmlLocalizer<IdentityResource> L
@inject ISettingManager SettingManager
@{ @{
Layout = null; 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"> <form asp-page="/Identity/Shared/PersonalSettingsModal">
@ -14,7 +22,7 @@
<abp-modal-header title="@L["PersonalInfo"].Value"></abp-modal-header> <abp-modal-header title="@L["PersonalInfo"].Value"></abp-modal-header>
<abp-modal-body> <abp-modal-body>
<abp-input asp-for="PersonalSettingsInfoModel.UserName" readonly="Model.IsUsernameUpdateDisabled" /> <abp-input asp-for="PersonalSettingsInfoModel.UserName" readonly="!isUserNameUpdateEnabled" />
<abp-row> <abp-row>
<abp-column size-md="_6"> <abp-column size-md="_6">
@ -25,7 +33,7 @@
</abp-column> </abp-column>
</abp-row> </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" /> <abp-input asp-for="PersonalSettingsInfoModel.PhoneNumber" />

35
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Shared/PersonalSettingsModal.cshtml.cs

@ -1,10 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Abp.Identity.Settings;
using Volo.Abp.Settings;
namespace Volo.Abp.Identity.Web.Pages.Identity.Shared namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
{ {
@ -12,19 +9,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Shared
{ {
[BindProperty] [BindProperty]
public PersonalSettingsInfoModel PersonalSettingsInfoModel { get; set; } 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; private readonly IProfileAppService _profileAppService;
public PersonalSettingsModal(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); 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); await _profileAppService.UpdateAsync(updateDto);
return NoContent(); return NoContent();

Loading…
Cancel
Save