ABPCMS.Application/ABPCMSAppServiceBase.cs
(完整代码) 1KBusing System;
using System.Threading.Tasks;
using Abp.Application.Services;
using Abp.IdentityFramework;
using Abp.Runtime.Session;
using ABPCMS.Authorization.Users;
using ABPCMS.MultiTenancy;
using ABPCMS.Users;
using Microsoft.AspNet.Identity;
namespace ABPCMS
{
/// <summary>
/// Derive your application services from this class.
/// </summary>
public abstract class ABPCMSAppServiceBase : ApplicationService
{
public TenantManager TenantManager { get; set; }
public UserManager UserManager { get; set; }
protected ABPCMSAppServiceBase()
{
LocalizationSourceName = ABPCMSConsts.LocalizationSourceName;
}
protected virtual Task<User> GetCurrentUserAsync()
{
var user = UserManager.FindByIdAsync(AbpSession.GetUserId());
if (user == null)
{
throw new ApplicationException("There is no current user!");
}
return user;
}
protected virtual Task<Tenant> GetCurrentTenantAsync()
{
return TenantManager.GetByIdAsync(AbpSession.GetTenantId());
}
protected virtual void CheckErrors(IdentityResult identityResult)
{
identityResult.CheckErrors(LocalizationManager);
}
}
}
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
