summaryrefslogtreecommitdiffstats
path: root/crates/auth/src/server/routes/authorised.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/auth/src/server/routes/authorised.rs')
-rw-r--r--crates/auth/src/server/routes/authorised.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/auth/src/server/routes/authorised.rs b/crates/auth/src/server/routes/authorised.rs
index 42bbde2..d493db5 100644
--- a/crates/auth/src/server/routes/authorised.rs
+++ b/crates/auth/src/server/routes/authorised.rs
@@ -43,7 +43,7 @@ struct User {
const SESSION_COOKIE: &str = "info";
const SESSION_DATA_KEY: &str = "data";
-async fn login_authorized(
+pub async fn login_authorised(
Query(query): Query<AuthRequest>,
State(state): State<AppHandle>,
TypedHeader(cookies): TypedHeader<headers::Cookie>,
@@ -52,8 +52,7 @@ async fn login_authorized(
cookies
.get(OAUTH_CSRF_COOKIE)
.context("missing session cookie")?,
- )
- .unwrap();
+ )?;
csrf_token_validation_workflow(&query, &state.session_store, oauth_session_id).await?;
let client = state.http_client.clone();
@@ -65,7 +64,7 @@ async fn login_authorized(
.exchange_code(AuthorizationCode::new(query.code.clone()))
.request_async(&client)
.await
- .context("failed in sending request request to authorization server")?;
+ .context("failed in sending request request to authorisation server")?;
let user_data: User = client
// https://discord.com/developers/docs/resources/user#get-current-user
@@ -76,7 +75,7 @@ async fn login_authorized(
.context("failed in sending request to target Url")?
.json::<User>()
.await
- .context("failed to deserialize response as JSON")?;
+ .context("failed to deserialise response as JSON")?;
// Create a new session filled with user data
let session_id = Id(i128::from_le_bytes(uuid::Uuid::new_v4().to_bytes_le()));
@@ -92,7 +91,7 @@ async fn login_authorized(
+ Duration::from_secs(state.local_config.oauth.session_lifespan),
})
.await
- .context("failed in inserting serialized value into session")?;
+ .context("failed in inserting serialised value into session")?;
// Store session and get corresponding cookie.
let cookie = format!("{SESSION_COOKIE}={session_id}; SameSite=Lax; HttpOnly; Secure; Path=/");