Skip to content

Commit

Permalink
Fix email domain validation (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Nov 10, 2023
1 parent 5b0c8b8 commit ea434c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/GZCTF/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task<IActionResult> Register([FromBody] RegisterModel model, Cancel
if (accountPolicy.Value.UseCaptcha && !await captcha.VerifyAsync(model, HttpContext, token))
return BadRequest(new RequestResponse("验证码校验失败"));

if (!VerifyEmailDomain(model.Email.Split('@')[1]))
if (!VerifyEmailDomain(model.Email))
return BadRequest(new RequestResponse($"可用邮箱后缀:{accountPolicy.Value.EmailDomainList}"));

var user = new UserInfo { UserName = model.UserName, Email = model.Email, Role = Role.User };
Expand Down Expand Up @@ -380,7 +380,7 @@ public async Task<IActionResult> ChangeEmail([FromBody] MailChangeModel model)
if (await userManager.FindByEmailAsync(model.NewMail) is not null)
return BadRequest(new RequestResponse("邮箱已经被占用"));

if (!VerifyEmailDomain(model.NewMail.Split('@')[1]))
if (!VerifyEmailDomain(model.NewMail))
return BadRequest(new RequestResponse($"可用邮箱后缀:{accountPolicy.Value.EmailDomainList}"));

UserInfo? user = await userManager.GetUserAsync(User);
Expand Down

0 comments on commit ea434c9

Please sign in to comment.