From 503653e9516824e0ed8b5e1b279420986db18b36 Mon Sep 17 00:00:00 2001 From: Moonbase Date: Sat, 26 Jul 2025 16:37:39 -0700 Subject: [PATCH] Verification Fixes --- qtc-net-server/Controllers/AuthController.cs | 6 +++--- qtc-net-server/Services/EmailService/EmailService.cs | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/qtc-net-server/Controllers/AuthController.cs b/qtc-net-server/Controllers/AuthController.cs index bdb69d0..2527db7 100644 --- a/qtc-net-server/Controllers/AuthController.cs +++ b/qtc-net-server/Controllers/AuthController.cs @@ -48,7 +48,7 @@ namespace qtc_api.Controllers { // send confirmation email (shouldn't do anything if email confirmation is disabled) var confirmationToken = _tokenService.GenerateEmailConfirmationToken(response.Data); - var confirmationUrl = $"{Request.Scheme}://{Request.Host}/api/auth/verify-email?token={confirmationToken}"; + var confirmationUrl = $"{Request.Scheme}://{Request.Host}/api/auth/verify-email?token={confirmationToken.Data}"; await _emailService.SendConfirmationEmail(response.Data.Email, response.Data.Username, confirmationUrl); @@ -120,7 +120,7 @@ namespace qtc_api.Controllers return Ok(response); } - [HttpPost("verify-email")] + [HttpGet("verify-email")] public async Task> VerifyEmail(string token) { try @@ -142,7 +142,7 @@ namespace qtc_api.Controllers if (user != null && user.Success && user.Data != null) { var now = DateTime.UtcNow; - if(user.Data.Email == email.Value && jwt.ValidTo.ToUniversalTime() < now) + if(user.Data.Email == email.Value && now < jwt.ValidTo.ToUniversalTime()) { user.Data.IsEmailVerified = true; await dataContext.SaveChangesAsync(); diff --git a/qtc-net-server/Services/EmailService/EmailService.cs b/qtc-net-server/Services/EmailService/EmailService.cs index 3072e04..1d1b106 100644 --- a/qtc-net-server/Services/EmailService/EmailService.cs +++ b/qtc-net-server/Services/EmailService/EmailService.cs @@ -38,20 +38,19 @@ namespace qtc_api.Services.EmailService // build confirmation email body StringBuilder emailBody = new(); - emailBody.AppendLine("Hello! This email was used to create an account on a QtC.NET Server."); + emailBody.AppendLine($"Hello {name},"); + emailBody.AppendLine(); + emailBody.AppendLine($"Your receiving this message because you made a QtC.NET Account on a server that requires email confirmation."); emailBody.AppendLine(); emailBody.AppendLine($"You can confirm your email by clicking here - {confirmUrl}"); emailBody.AppendLine(); emailBody.AppendLine("If you did not create a QtC.NET account on any server, you may simply ignore this email."); // create new client - using var client = new SmtpClient() - { - RequireTLS = true - }; + using var client = new SmtpClient(); // connect and authenticate - await client.ConnectAsync(host, 587, true); + await client.ConnectAsync(host, 587); await client.AuthenticateAsync(username, password); // construct email