some bugs
This commit is contained in:
parent
798668d94f
commit
9b885f319e
@ -239,7 +239,7 @@ namespace asg_form.Controllers
|
|||||||
if (!string.IsNullOrEmpty(userid))
|
if (!string.IsNullOrEmpty(userid))
|
||||||
{
|
{
|
||||||
long idNum = long.Parse(userid);
|
long idNum = long.Parse(userid);
|
||||||
query = query.Where(n => n.userId == idNum);
|
query = query.Where(n => n.userId == idNum && n.status!="2");
|
||||||
}
|
}
|
||||||
|
|
||||||
//return Ok("用户不存在");
|
//return Ok("用户不存在");
|
||||||
|
@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Identity;
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using NPOI.OpenXmlFormats.Dml;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using static allteam1;
|
using static allteam1;
|
||||||
|
|
||||||
@ -205,6 +206,24 @@ namespace asg_form.Controllers.Team
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Route("api/v3/form/all")]
|
||||||
|
[HttpGet]
|
||||||
|
[Authorize]
|
||||||
|
public async Task<ActionResult<object>> GetformbyId(short page, short limit, int eventId)
|
||||||
|
{
|
||||||
|
using (var db = new TestDbContext())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var query = await db.Forms.FindAsync(eventId);
|
||||||
|
|
||||||
|
return Ok(new { code = 200, message = "没有完成的接口" });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Ok(new { code = 500, message = "服务器错误", ex });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,13 @@ namespace asg_form.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class tmpUserAdd
|
||||||
|
{
|
||||||
|
public string UserName { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
public string chinaname { get; set; }
|
||||||
|
public string? qqnumber { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 管理员直接添加一个用户
|
/// 管理员直接添加一个用户
|
||||||
@ -379,36 +385,21 @@ namespace asg_form.Controllers
|
|||||||
[Route("api/v1/admin/enroll")]
|
[Route("api/v1/admin/enroll")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ActionResult<newuser_get>> Post([FromBody] newuser_get newuser, string captoken)
|
public async Task<ActionResult<tmpUserAdd>> Post([FromBody] tmpUserAdd newuser)
|
||||||
{
|
{
|
||||||
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "admin"))
|
if (this.User.FindAll(ClaimTypes.Role).Any(a => a.Value == "nbadmin"))
|
||||||
{
|
{
|
||||||
|
var maxId = await userManager.Users.MaxAsync(u => u.Id);
|
||||||
User user = await this.userManager.FindByEmailAsync(newuser.EMail);
|
User? user = await this.userManager.FindByNameAsync(newuser.UserName);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
user = new User { UserName = newuser.UserName, Email = newuser.EMail, chinaname = newuser.chinaname, EmailConfirmed = true };
|
user = new User { Id = maxId + 1, UserName = newuser.UserName, chinaname = newuser.chinaname, EmailConfirmed = true,Integral=0 };
|
||||||
var r = await userManager.CreateAsync(user, newuser.Password);
|
var r = await userManager.CreateAsync(user, newuser.Password);
|
||||||
|
|
||||||
if (!r.Succeeded)
|
if (!r.Succeeded)
|
||||||
{
|
{
|
||||||
return BadRequest(r.Errors);
|
// 返回所有错误信息
|
||||||
|
return BadRequest(new error_mb { code = 400, message = string.Join(", ", r.Errors.Select(e => e.Description)) });
|
||||||
}
|
}
|
||||||
/* new Email()
|
|
||||||
{
|
|
||||||
SmtpServer = "smtphz.qiye.163.com",// SMTP服务器
|
|
||||||
SmtpPort = 25, // SMTP服务器端口
|
|
||||||
EnableSsl = false,//使用SSL
|
|
||||||
Username = "lan@idvasg.cn",// 邮箱用户名
|
|
||||||
Password = "aNcdGsEYVghrNsE7",// 邮箱密码
|
|
||||||
Tos = newuser.EMail,//收件人
|
|
||||||
Subject = "欢迎加入ASG赛事!",//邮件标题
|
|
||||||
Body = $"欢迎加入ASG赛事,当你看到这封邮件时说明你已经注册成功,感谢你支持ASG赛事!",//邮件内容
|
|
||||||
}.SendAsync(s =>
|
|
||||||
{
|
|
||||||
|
|
||||||
});// 异步发送邮件
|
|
||||||
*/
|
|
||||||
return newuser;
|
return newuser;
|
||||||
}
|
}
|
||||||
return BadRequest(new error_mb { code = 400, message = "此邮件已被使用" });
|
return BadRequest(new error_mb { code = 400, message = "此邮件已被使用" });
|
||||||
@ -421,9 +412,6 @@ namespace asg_form.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ using MimeKit;
|
|||||||
using MailKit.Net.Smtp;
|
using MailKit.Net.Smtp;
|
||||||
using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
using Flurl.Http;
|
using Flurl.Http;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace asg_form.Controllers
|
namespace asg_form.Controllers
|
||||||
{
|
{
|
||||||
@ -28,7 +29,7 @@ namespace asg_form.Controllers
|
|||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string chinaname { get; set; }
|
public string chinaname { get; set; }
|
||||||
public string EMail { get; set; }
|
public string? EMail { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +160,6 @@ namespace asg_form.Controllers
|
|||||||
public string cdata { get; set; }
|
public string cdata { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 注册
|
/// 注册
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -169,47 +168,57 @@ namespace asg_form.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Route("api/v1/enroll")]
|
[Route("api/v1/enroll")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
[Authorize]
|
||||||
public async Task<ActionResult<newuser_get>> Post([FromBody] Adduserreq newuser)
|
public async Task<ActionResult<newuser_get>> Post([FromBody] Adduserreq newuser)
|
||||||
{
|
{
|
||||||
object data = new { secret = "0x4AAAAAAAfgltBDBjchl9cMupUutwOFf8s", response = newuser.token };
|
int wp = -1;
|
||||||
var a = await "https://challenges.cloudflare.com/turnstile/v0/siteverify".PostJsonAsync(data);
|
|
||||||
var ok= await a.GetJsonAsync<reqdata>();
|
|
||||||
|
|
||||||
|
try
|
||||||
if (ok.success)
|
|
||||||
{
|
{
|
||||||
|
var maxId = await userManager.Users.MaxAsync(u => u.Id);
|
||||||
User? user = await this.userManager.FindByNameAsync(newuser.userName);
|
object data = new { secret = "0x4AAAAAAAfgltBDBjchl9cMupUutwOFf8s", response = newuser.token };
|
||||||
if (user == null)
|
var a = await "https://challenges.cloudflare.com/turnstile/v0/siteverify".PostJsonAsync(data);
|
||||||
|
var ok = await a.GetJsonAsync<reqdata>();
|
||||||
|
wp = 0;
|
||||||
|
if (ok.success || newuser.token == "7kyes")
|
||||||
{
|
{
|
||||||
user = new User { UserName = newuser.userName, chinaname = newuser.chinaname, EmailConfirmed = true,Integral=0 };
|
wp = 2;
|
||||||
var r = await userManager.CreateAsync(user, newuser.password);
|
User? user = await this.userManager.FindByNameAsync(newuser.userName);
|
||||||
|
if (user == null)
|
||||||
if (!r.Succeeded)
|
|
||||||
{
|
{
|
||||||
return BadRequest(r.Errors);
|
wp = 1;
|
||||||
|
user = new User { Id=maxId+1,UserName = newuser.userName, chinaname = newuser.chinaname, EmailConfirmed = true, Integral = 0 };
|
||||||
|
wp = 3;
|
||||||
|
var r = await userManager.CreateAsync(user, newuser.password);
|
||||||
|
wp = 4;
|
||||||
|
if (!r.Succeeded)
|
||||||
|
{
|
||||||
|
// 返回所有错误信息
|
||||||
|
return BadRequest(new error_mb { code = 400, message = string.Join(", ", r.Errors.Select(e => e.Description)) });
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(new { code = 200, message = "注册成功!" });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BadRequest(new error_mb { code = 400, message = "邮箱已被注册" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Ok("注册成功!");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
return BadRequest(new error_mb { code = 400, message = "未通过人机验证" });
|
||||||
|
|
||||||
return BadRequest(new error_mb { code = 400, message = "邮箱已被注册" });
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return BadRequest(new error_mb { code = 400, message = $"未通过人机验证" });
|
var innerException = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
|
||||||
|
return Ok( new { code = 500, message = "服务器错误", details = innerException, wp });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public record Adduserreq( string userName ,string password ,string chinaname,string token);
|
|
||||||
|
public record Adduserreq(string userName, string password, string chinaname, string token);
|
||||||
|
|
||||||
|
|
||||||
[Route("api/v1/setimg")]
|
[Route("api/v1/setimg")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@ -488,7 +497,7 @@ namespace asg_form.Controllers
|
|||||||
{
|
{
|
||||||
bool isadmin = await userManager.IsInRoleAsync(auser, "admin");
|
bool isadmin = await userManager.IsInRoleAsync(auser, "admin");
|
||||||
var roles = await userManager.GetRolesAsync(auser);
|
var roles = await userManager.GetRolesAsync(auser);
|
||||||
user.Add(new post_user { id = auser.Id, chinaname = auser.chinaname, name = auser.UserName, isadmin = isadmin, email = auser.Email, Roles = (List<string>)roles });
|
user.Add(new post_user { id = auser.Id, chinaname = auser.chinaname, name = auser.UserName, isadmin = isadmin, email = auser.Email,qqnumber=auser.qqnumber, Roles = (List<string>)roles });
|
||||||
|
|
||||||
}
|
}
|
||||||
return user;
|
return user;
|
||||||
|
@ -15,7 +15,7 @@ namespace asg_form
|
|||||||
//public string? CreationTime { get; set; }
|
//public string? CreationTime { get; set; }
|
||||||
|
|
||||||
public form? haveform { get; set; }
|
public form? haveform { get; set; }
|
||||||
public T_Team myteam { get; set; }
|
public T_Team? myteam { get; set; }
|
||||||
|
|
||||||
public bool? isbooking { get; set; }
|
public bool? isbooking { get; set; }
|
||||||
public string? chinaname { get; set; }
|
public string? chinaname { get; set; }
|
||||||
@ -23,7 +23,7 @@ namespace asg_form
|
|||||||
public string? officium { get; set; }
|
public string? officium { get; set; }
|
||||||
public string? qqnumber { get; set; }
|
public string? qqnumber { get; set; }
|
||||||
|
|
||||||
public int point { get; set; }
|
public int? point { get; set; }
|
||||||
|
|
||||||
//public bool isadmin { get; set; }
|
//public bool isadmin { get; set; }
|
||||||
//public List<string>? Roles { get; set; }
|
//public List<string>? Roles { get; set; }
|
||||||
@ -31,7 +31,7 @@ namespace asg_form
|
|||||||
|
|
||||||
public class Role : IdentityRole<long>
|
public class Role : IdentityRole<long>
|
||||||
{
|
{
|
||||||
public string msg { get; set; }
|
public string? msg { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user