aboutsummaryrefslogtreecommitdiffstats
path: root/crates/api-auth/src/discord
diff options
context:
space:
mode:
Diffstat (limited to 'crates/api-auth/src/discord')
-rw-r--r--crates/api-auth/src/discord/mod.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/crates/api-auth/src/discord/mod.rs b/crates/api-auth/src/discord/mod.rs
index 29b9bc2..dbcb139 100644
--- a/crates/api-auth/src/discord/mod.rs
+++ b/crates/api-auth/src/discord/mod.rs
@@ -2,19 +2,25 @@ use api_core::models::user::User;
use async_session::Session;
use async_trait::async_trait;
use oauth2::{CsrfToken, Scope};
+use sh_util::cache::RedisManager;
use sqlx::PgPool;
use crate::{BasicClient, CSRF_TOKEN, OauthDriver, error::AuthError};
-#[derive(Clone, Debug)]
+#[derive(Clone)]
pub struct AuthServiceDiscord {
database: PgPool,
+ cache: RedisManager,
client: BasicClient,
}
impl AuthServiceDiscord {
- pub fn new(database: PgPool, client: BasicClient) -> Self {
- Self { database, client }
+ pub fn new(database: PgPool, client: BasicClient, cache: RedisManager) -> Self {
+ Self {
+ database,
+ client,
+ cache,
+ }
}
}
@@ -26,7 +32,7 @@ impl OauthDriver for AuthServiceDiscord {
async fn get_user(&self) -> Result<User, AuthError> {
todo!()
}
- async fn create_oauth_session(&self)->Result<String,AuthError> {
+ async fn create_oauth_session(&self) -> Result<String, AuthError> {
let (auth_url, csrf_token) = self
.client
.authorize_url(CsrfToken::new_random)
@@ -38,7 +44,7 @@ impl OauthDriver for AuthServiceDiscord {
Ok(String::default())
}
- async fn save_session(&self, user: &User)->Result<(), AuthError>{
+ async fn save_session(&self, user: &User) -> Result<(), AuthError> {
todo!()
}
}