finish verify endpoint
This commit is contained in:
parent
b626220fd3
commit
16acd9b772
2 changed files with 16 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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<IResult> HandleRegister(HttpContext context)
|
||||
|
|
Loading…
Reference in a new issue