feat: 完成登录校验拦截
This commit is contained in:
@@ -91,22 +91,22 @@ public class AiChatService : ApplicationService
|
||||
public async Task PostSendAsync(SendMessageInput input, CancellationToken cancellationToken)
|
||||
{
|
||||
//除了免费模型,其他的模型都要校验
|
||||
// if (input.Model != "DeepSeek-R1-0528")
|
||||
// {
|
||||
// //有token,需要黑名单校验
|
||||
// if (CurrentUser.IsAuthenticated)
|
||||
// {
|
||||
// await _aiBlacklistManager.VerifiyAiBlacklist(CurrentUser.GetId());
|
||||
// if (!CurrentUser.Roles.Contains("YiXinAi-Vip"))
|
||||
// {
|
||||
// throw new UserFriendlyException("该模型需要VIP用户才能使用,请购买VIP后重新登录重试");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new UserFriendlyException("未登录用户,只能使用未加速的DeepSeek-R1,请登录后重试");
|
||||
// }
|
||||
// }
|
||||
if (input.Model != "DeepSeek-R1")
|
||||
{
|
||||
//有token,需要黑名单校验
|
||||
if (CurrentUser.IsAuthenticated)
|
||||
{
|
||||
await _aiBlacklistManager.VerifiyAiBlacklist(CurrentUser.GetId());
|
||||
if (!CurrentUser.Roles.Contains("YiXinAi-Vip")&&!CurrentUser.Roles.Contains("admin"))
|
||||
{
|
||||
throw new UserFriendlyException("该模型需要VIP用户才能使用,请购买VIP后重新登录重试");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UserFriendlyException("未登录用户,只能使用未加速的DeepSeek-R1,请登录后重试");
|
||||
}
|
||||
}
|
||||
|
||||
//前面都是校验,后面才是真正的调用
|
||||
var httpContext = this._httpContextAccessor.HttpContext;
|
||||
|
||||
Reference in New Issue
Block a user