finish verify endpoint

This commit is contained in:
Elijah R 2024-04-04 01:14:52 -04:00
parent b626220fd3
commit 16acd9b772
2 changed files with 16 additions and 0 deletions

View file

@ -100,4 +100,15 @@ public class Database
cmd.Parameters.AddWithValue("@email_verification_code", verificationcode); cmd.Parameters.AddWithValue("@email_verification_code", verificationcode);
await cmd.ExecuteNonQueryAsync(); 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();
}
} }

View file

@ -70,6 +70,11 @@ public static class Routes
}, Utilities.JsonSerializerOptions); }, Utilities.JsonSerializerOptions);
} }
// Verify the account // Verify the account
await Program.Database.SetUserVerified(payload.username, true);
return Results.Json(new RegisterResponse
{
success = true
}, Utilities.JsonSerializerOptions);
} }
private static async Task<IResult> HandleRegister(HttpContext context) private static async Task<IResult> HandleRegister(HttpContext context)