From 16acd9b772c0835a02e3032e95747859e859ea9c Mon Sep 17 00:00:00 2001 From: Elijah R Date: Thu, 4 Apr 2024 01:14:52 -0400 Subject: [PATCH] finish verify endpoint --- CollabVMAuthServer/Database.cs | 11 +++++++++++ CollabVMAuthServer/Routes.cs | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/CollabVMAuthServer/Database.cs b/CollabVMAuthServer/Database.cs index ffd3bf5..c739efd 100644 --- a/CollabVMAuthServer/Database.cs +++ b/CollabVMAuthServer/Database.cs @@ -100,4 +100,15 @@ public class Database cmd.Parameters.AddWithValue("@email_verification_code", verificationcode); await cmd.ExecuteNonQueryAsync(); } + + public async Task SetUserVerified(string username, bool verified) + { + await using var db = new MySqlConnection(connectionString); + await db.OpenAsync(); + await using var cmd = db.CreateCommand(); + cmd.CommandText = "UPDATE users SET email_verified = @verified WHERE username = @username"; + cmd.Parameters.AddWithValue("@verified", verified); + cmd.Parameters.AddWithValue("@username", username); + await cmd.ExecuteNonQueryAsync(); + } } \ No newline at end of file diff --git a/CollabVMAuthServer/Routes.cs b/CollabVMAuthServer/Routes.cs index 0e172bb..fd0a284 100644 --- a/CollabVMAuthServer/Routes.cs +++ b/CollabVMAuthServer/Routes.cs @@ -70,6 +70,11 @@ public static class Routes }, Utilities.JsonSerializerOptions); } // Verify the account + await Program.Database.SetUserVerified(payload.username, true); + return Results.Json(new RegisterResponse + { + success = true + }, Utilities.JsonSerializerOptions); } private static async Task HandleRegister(HttpContext context)