This commit is contained in:
王炜翔 2024-11-11 15:55:46 +08:00
commit e836c3337f
2 changed files with 12 additions and 16 deletions

View File

@ -175,21 +175,21 @@ namespace asg_form.Controllers
{ {
int wp = -1; int wp = -1;
try
{
var maxId = await userManager.Users.MaxAsync(u => u.Id); var maxId = await userManager.Users.MaxAsync(u => u.Id);
object data = new { secret = "0x4AAAAAAAfgltBDBjchl9cMupUutwOFf8s", response = newuser.token }; object data = new { id = "67134feddc0ff12924d9aaf4", secretkey = "c3e08b07b8034e6b961f010abed5586a", scene= 3,token=newuser.token,ip=newuser.ip};
var a = await "https://challenges.cloudflare.com/turnstile/v0/siteverify".PostJsonAsync(data); var a = await newuser.server.PostJsonAsync(data);
var ok = await a.GetJsonAsync<reqdata>(); var ok = await a.GetJsonAsync();
Console.WriteLine(ok);
wp = 0; wp = 0;
if (ok.success || newuser.token == "7kyes") if (ok.success ==1)
{ {
wp = 2; wp = 2;
User? user = await this.userManager.FindByNameAsync(newuser.userName); User? user = await this.userManager.FindByNameAsync(newuser.userName);
if (user == null) if (user == null)
{ {
wp = 1; wp = 1;
user = new User { Id=maxId+1,UserName = newuser.userName, chinaname = newuser.chinaname, EmailConfirmed = true, Integral = 0 }; user = new User { Id=maxId+1,UserName = newuser.userName, chinaname = newuser.chinaname, EmailConfirmed = true, Integral = 0 ,qqnumber=newuser.qqNumber};
wp = 3; wp = 3;
var r = await userManager.CreateAsync(user, newuser.password); var r = await userManager.CreateAsync(user, newuser.password);
wp = 4; wp = 4;
@ -208,14 +208,9 @@ namespace asg_form.Controllers
} }
else else
{ {
return BadRequest(new error_mb { code = 400, message = "未通过人机验证" }); return BadRequest(new error_mb { code = 400, message = $"未通过人机验证{await a.GetStringAsync()}" });
} }
}
catch (Exception ex)
{
var innerException = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
return Ok( new { code = 500, message = "服务器错误", details = innerException, wp });
}
} }
public readonly CaptchaService _captchaService = new CaptchaService(); public readonly CaptchaService _captchaService = new CaptchaService();
@ -362,7 +357,7 @@ namespace asg_form.Controllers
public record Adduserreq(string userName, string password, string chinaname, string token); public record Adduserreq(string userName, string password, string chinaname, string server,string token,string ip, string qqNumber);
public record AddUserReq(string userName, string password, string chinaname, string captcha,string uid); public record AddUserReq(string userName, string password, string chinaname, string captcha,string uid);

View File

@ -5,6 +5,7 @@ using Flandre.Adapters.OneBot.Extensions;
using Flandre.Framework; using Flandre.Framework;
using IGeekFan.AspNetCore.Knife4jUI; using IGeekFan.AspNetCore.Knife4jUI;
using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -149,7 +150,7 @@ var app = builder.Build();
app.UseCors(); app.UseCors();
// Configure the HTTP request pipeline. // Configure the HTTP request pipeline.
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(); app.UseSwaggerUI();
app.UseKnife4UI(c => app.UseKnife4UI(c =>
{ {