Labrinth ID cleanup (#3681)

* Put all ID types in the labrinth::models::ids, and reduce code duplication with them

* Rewrite labrinth::database::models::ids and rename most DB interface ID structs to be prefixed with DB

* Run sqlx prepare

---------

Co-authored-by: Alejandro González <7822554+AlexTMjugador@users.noreply.github.com>
This commit is contained in:
Josiah Glosson
2025-05-22 03:34:36 -05:00
committed by GitHub
parent c6022ad977
commit 9e527ff141
111 changed files with 1477 additions and 1965 deletions

View File

@@ -1,6 +1,6 @@
use super::errors::OAuthError;
use crate::auth::oauth::OAuthErrorType;
use crate::database::models::OAuthClientId;
use crate::database::models::DBOAuthClientId;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
@@ -16,7 +16,7 @@ impl ValidatedRedirectUri {
pub fn validate<'a>(
to_validate: &Option<String>,
validate_against: impl IntoIterator<Item = &'a str> + Clone,
client_id: OAuthClientId,
client_id: DBOAuthClientId,
) -> Result<Self, OAuthError> {
if let Some(first_client_redirect_uri) =
validate_against.clone().into_iter().next()
@@ -61,7 +61,7 @@ mod tests {
let validated = ValidatedRedirectUri::validate(
&None,
validate_against.clone(),
OAuthClientId(0),
DBOAuthClientId(0),
)
.unwrap();
@@ -82,7 +82,7 @@ mod tests {
let validated = ValidatedRedirectUri::validate(
&Some(to_validate.clone()),
validate_against,
OAuthClientId(0),
DBOAuthClientId(0),
)
.unwrap();
@@ -97,7 +97,7 @@ mod tests {
let validated = ValidatedRedirectUri::validate(
&Some(to_validate),
validate_against,
OAuthClientId(0),
DBOAuthClientId(0),
);
assert!(validated.is_err_and(|e| matches!(