diff options
Diffstat (limited to 'src/auth/service.rs')
-rw-r--r-- | src/auth/service.rs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/auth/service.rs b/src/auth/service.rs deleted file mode 100644 index b9b44d4..0000000 --- a/src/auth/service.rs +++ /dev/null @@ -1,40 +0,0 @@ -use actix_web::web::{Data, Query}; -use actix_web::{get, HttpResponse}; -use serde::Deserialize; -use tokio::sync::mpsc; - -use crate::auth::AuthCode; - -#[derive(Debug, Deserialize)] -struct AuthCodeQuery -{ - error_reason: Option<String>, - code: Option<AuthCode>, -} - -#[get("/")] -async fn retrieve_auth_code( - query: Query<AuthCodeQuery>, - done_tx: Data<mpsc::Sender<AuthCode>>, -) -> HttpResponse -{ - if let Some(error_reason) = &query.error_reason { - return HttpResponse::Unauthorized().body(format!( - "Error: No authentication code was retrieved. Reason: {}\n\nYou can close this tab", - error_reason - )); - } - - let auth_code = match &query.code { - Some(auth_code) => auth_code, - None => { - return HttpResponse::BadRequest() - .body("Error: No authentication code was retrieved"); - } - }; - - done_tx.send(auth_code.clone()).await.unwrap(); - - HttpResponse::Ok() - .body("Authentication code was successfully retrieved.\n\nYou can close this tab") -} |