|
|
@ -1,13 +1,19 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
|
|
using Microsoft.AspNetCore.Http.Extensions; |
|
|
using Microsoft.AspNetCore.Identity; |
|
|
using Microsoft.AspNetCore.Identity; |
|
|
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.Extensions.Options; |
|
|
using Microsoft.Extensions.Options; |
|
|
using Volo.Abp.Account.Localization; |
|
|
using Volo.Abp.Account.Localization; |
|
|
using Volo.Abp.AspNetCore.ExceptionHandling; |
|
|
using Volo.Abp.AspNetCore.ExceptionHandling; |
|
|
|
|
|
using Volo.Abp.AspNetCore.MultiTenancy; |
|
|
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|
|
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; |
|
|
using Volo.Abp.ExceptionHandling; |
|
|
using Volo.Abp.ExceptionHandling; |
|
|
using Volo.Abp.Identity; |
|
|
using Volo.Abp.Identity; |
|
|
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
using IdentityUser = Volo.Abp.Identity.IdentityUser; |
|
|
using IdentityUser = Volo.Abp.Identity.IdentityUser; |
|
|
|
|
|
|
|
|
namespace Volo.Abp.Account.Web.Pages.Account |
|
|
namespace Volo.Abp.Account.Web.Pages.Account |
|
|
@ -21,12 +27,50 @@ namespace Volo.Abp.Account.Web.Pages.Account |
|
|
public IOptions<IdentityOptions> IdentityOptions { get; set; } |
|
|
public IOptions<IdentityOptions> IdentityOptions { get; set; } |
|
|
public IExceptionToErrorInfoConverter ExceptionToErrorInfoConverter { get; set; } |
|
|
public IExceptionToErrorInfoConverter ExceptionToErrorInfoConverter { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public ITenantResolveResultAccessor TenantResolveResultAccessor { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public IOptions<AbpAspNetCoreMultiTenancyOptions> AspNetCoreMultiTenancyOptions { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public IOptions<AbpMultiTenancyOptions> MultiTenancyOptions { get; set; } |
|
|
|
|
|
|
|
|
protected AccountPageModel() |
|
|
protected AccountPageModel() |
|
|
{ |
|
|
{ |
|
|
LocalizationResourceType = typeof(AccountResource); |
|
|
LocalizationResourceType = typeof(AccountResource); |
|
|
ObjectMapperContext = typeof(AbpAccountWebModule); |
|
|
ObjectMapperContext = typeof(AbpAccountWebModule); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected virtual bool SwitchTenant(Guid? tenantId) |
|
|
|
|
|
{ |
|
|
|
|
|
if (MultiTenancyOptions.Value.IsEnabled && |
|
|
|
|
|
TenantResolveResultAccessor.Result?.AppliedResolvers?.Contains(CookieTenantResolveContributor.ContributorName) == true) |
|
|
|
|
|
{ |
|
|
|
|
|
if (CurrentTenant.Id != tenantId) |
|
|
|
|
|
{ |
|
|
|
|
|
if (tenantId != null) |
|
|
|
|
|
{ |
|
|
|
|
|
Response.Cookies.Append( |
|
|
|
|
|
AspNetCoreMultiTenancyOptions.Value.TenantKey, |
|
|
|
|
|
tenantId.ToString(), |
|
|
|
|
|
new CookieOptions |
|
|
|
|
|
{ |
|
|
|
|
|
Path = "/", |
|
|
|
|
|
HttpOnly = false, |
|
|
|
|
|
Expires = DateTimeOffset.Now.AddYears(10) |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
Response.Cookies.Delete(AspNetCoreMultiTenancyOptions.Value.TenantKey); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
protected virtual void CheckIdentityErrors(IdentityResult identityResult) |
|
|
protected virtual void CheckIdentityErrors(IdentityResult identityResult) |
|
|
{ |
|
|
{ |
|
|
if (!identityResult.Succeeded) |
|
|
if (!identityResult.Succeeded) |
|
|
|