You've already forked AstralRinth
forked from didirus/AstralRinth
Commonize and distinguish a lot of struct names in labrinth::database::models (#3691)
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
use crate::auth::get_user_from_headers;
|
||||
use crate::auth::oauth::uris::{OAuthRedirectUris, ValidatedRedirectUri};
|
||||
use crate::auth::validate::extract_authorization_header;
|
||||
use crate::database::models::flow_item::Flow;
|
||||
use crate::database::models::oauth_client_authorization_item::OAuthClientAuthorization;
|
||||
use crate::database::models::oauth_client_item::OAuthClient as DBOAuthClient;
|
||||
use crate::database::models::oauth_token_item::OAuthAccessToken;
|
||||
use crate::database::models::flow_item::DBFlow;
|
||||
use crate::database::models::oauth_client_authorization_item::DBOAuthClientAuthorization;
|
||||
use crate::database::models::oauth_client_item::DBOAuthClient;
|
||||
use crate::database::models::oauth_token_item::DBOAuthAccessToken;
|
||||
use crate::database::models::{
|
||||
DBOAuthClientAuthorizationId, generate_oauth_access_token_id,
|
||||
generate_oauth_client_authorization_id,
|
||||
@@ -106,7 +106,7 @@ pub async fn init_oauth(
|
||||
}
|
||||
|
||||
let existing_authorization =
|
||||
OAuthClientAuthorization::get(client.id, user.id.into(), &**pool)
|
||||
DBOAuthClientAuthorization::get(client.id, user.id.into(), &**pool)
|
||||
.await
|
||||
.map_err(|e| {
|
||||
OAuthError::redirect(e, &oauth_info.state, &redirect_uri)
|
||||
@@ -131,7 +131,7 @@ pub async fn init_oauth(
|
||||
.await
|
||||
}
|
||||
_ => {
|
||||
let flow_id = Flow::InitOAuthAppApproval {
|
||||
let flow_id = DBFlow::InitOAuthAppApproval {
|
||||
user_id: user.id.into(),
|
||||
client_id: client.id,
|
||||
existing_authorization_id: existing_authorization
|
||||
@@ -231,13 +231,13 @@ pub async fn request_token(
|
||||
|
||||
// Ensure auth code is single use
|
||||
// per IETF RFC6749 Section 10.5 (https://datatracker.ietf.org/doc/html/rfc6749#section-10.5)
|
||||
let flow = Flow::take_if(
|
||||
let flow = DBFlow::take_if(
|
||||
&req_params.code,
|
||||
|f| matches!(f, Flow::OAuthAuthorizationCodeSupplied { .. }),
|
||||
|f| matches!(f, DBFlow::OAuthAuthorizationCodeSupplied { .. }),
|
||||
&redis,
|
||||
)
|
||||
.await?;
|
||||
if let Some(Flow::OAuthAuthorizationCodeSupplied {
|
||||
if let Some(DBFlow::OAuthAuthorizationCodeSupplied {
|
||||
user_id,
|
||||
client_id,
|
||||
authorization_id,
|
||||
@@ -274,8 +274,8 @@ pub async fn request_token(
|
||||
let token_id =
|
||||
generate_oauth_access_token_id(&mut transaction).await?;
|
||||
let token = generate_access_token();
|
||||
let token_hash = OAuthAccessToken::hash_token(&token);
|
||||
let time_until_expiration = OAuthAccessToken {
|
||||
let token_hash = DBOAuthAccessToken::hash_token(&token);
|
||||
let time_until_expiration = DBOAuthAccessToken {
|
||||
id: token_id,
|
||||
authorization_id,
|
||||
token_hash,
|
||||
@@ -328,13 +328,13 @@ pub async fn accept_or_reject_client_scopes(
|
||||
.await?
|
||||
.1;
|
||||
|
||||
let flow = Flow::take_if(
|
||||
let flow = DBFlow::take_if(
|
||||
&body.flow,
|
||||
|f| matches!(f, Flow::InitOAuthAppApproval { .. }),
|
||||
|f| matches!(f, DBFlow::InitOAuthAppApproval { .. }),
|
||||
&redis,
|
||||
)
|
||||
.await?;
|
||||
if let Some(Flow::InitOAuthAppApproval {
|
||||
if let Some(DBFlow::InitOAuthAppApproval {
|
||||
user_id,
|
||||
client_id,
|
||||
existing_authorization_id,
|
||||
@@ -359,7 +359,7 @@ pub async fn accept_or_reject_client_scopes(
|
||||
.await?
|
||||
}
|
||||
};
|
||||
OAuthClientAuthorization::upsert(
|
||||
DBOAuthClientAuthorization::upsert(
|
||||
auth_id,
|
||||
client_id,
|
||||
user_id,
|
||||
@@ -425,7 +425,7 @@ async fn init_oauth_code_flow(
|
||||
state: Option<String>,
|
||||
redis: &RedisPool,
|
||||
) -> Result<HttpResponse, OAuthError> {
|
||||
let code = Flow::OAuthAuthorizationCodeSupplied {
|
||||
let code = DBFlow::OAuthAuthorizationCodeSupplied {
|
||||
user_id,
|
||||
client_id: client_id.into(),
|
||||
authorization_id,
|
||||
|
||||
Reference in New Issue
Block a user