aboutsummaryrefslogtreecommitdiffstats
path: root/src/server/state
diff options
context:
space:
mode:
authorrtkay123 <dev@kanjala.com>2026-02-02 13:30:25 +0200
committerrtkay123 <dev@kanjala.com>2026-02-02 13:30:25 +0200
commit549d98f3b457ddfc6dffbe2fad406da4ac50ebc7 (patch)
treed1563d048eb7600f0f1265766efffb2797280051 /src/server/state
parente06094f23ca861ea5ae4864d11fa8ce8b7d7aa2c (diff)
downloadsellershut-549d98f3b457ddfc6dffbe2fad406da4ac50ebc7.tar.bz2
sellershut-549d98f3b457ddfc6dffbe2fad406da4ac50ebc7.zip
refactor: collapse auth
Diffstat (limited to 'src/server/state')
-rw-r--r--src/server/state/mod.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/server/state/mod.rs b/src/server/state/mod.rs
index f5f731e..03e8c70 100644
--- a/src/server/state/mod.rs
+++ b/src/server/state/mod.rs
@@ -3,25 +3,25 @@ pub mod federation;
use std::sync::Arc;
-use sellershut_auth::{ClientOptions, OauthClient};
#[cfg(feature = "oauth-discord")]
use url::Url;
#[cfg(feature = "oauth-discord")]
-use crate::config::DiscordOauth;
+use crate::{config::DiscordOauth, server::driver::auth::OauthClient};
use crate::{config::Config, server::driver::SellershutDriver};
#[derive(Clone)]
pub struct AppState {
driver: Arc<dyn SellershutDriver>,
#[cfg(feature = "oauth-discord")]
- oauth_discord: OauthClient,
+ pub oauth_discord: OauthClient,
}
impl AppState {
pub async fn new(config: &Config, driver: impl SellershutDriver) -> anyhow::Result<Self> {
Ok(Self {
driver: Arc::new(driver),
+ #[cfg(feature = "oauth-discord")]
oauth_discord: discord_client(&config.oauth.discord, &config.oauth.oauth_redirect_url)?,
})
}
@@ -29,6 +29,8 @@ impl AppState {
#[cfg(feature = "oauth-discord")]
fn discord_client(disc: &DiscordOauth, redirect: &Url) -> anyhow::Result<OauthClient> {
+ use crate::server::driver::{self, auth::ClientOptions};
+
let discord_opts = ClientOptions::builder()
.client_id(disc.client_id.to_owned())
.redirect_url(redirect.to_string())
@@ -37,5 +39,5 @@ fn discord_client(disc: &DiscordOauth, redirect: &Url) -> anyhow::Result<OauthCl
.token_url(disc.token_url.to_string())
.build();
- Ok(sellershut_auth::oauth_client(&discord_opts)?)
+ Ok(driver::auth::oauth_client(&discord_opts)?)
}