src/Newdtek.Master.Application/MasterAppServiceBase.cs
(完整代码) 1KBusing System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Abp.Application.Services;
using Abp.IdentityFramework;
using Abp.Runtime.Session;
using Newdtek.Master.Authorization.Users;
using Newdtek.Master.MultiTenancy;
namespace Newdtek.Master
{
/// <summary>
/// Derive your application services from this class.
/// </summary>
public abstract class MasterAppServiceBase : ApplicationService
{
public TenantManager TenantManager { get; set; }
public UserManager UserManager { get; set; }
protected MasterAppServiceBase()
{
LocalizationSourceName = MasterConsts.LocalizationSourceName;
}
protected virtual async Task<User> GetCurrentUserAsync()
{
var user = await UserManager.FindByIdAsync(AbpSession.GetUserId().ToString());
if (user == null)
{
throw new Exception("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 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。