diff options
author | HampusM <hampus@hampusmat.com> | 2022-09-09 20:03:02 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-09-09 20:04:54 +0200 |
commit | db42316544c65951c7781357ec5aaba1b9abb8ab (patch) | |
tree | 13fd19efb80cf29f054c1760e8580f4379ce6a6a /src/auth/service.rs | |
parent | 8a02d3386d4ce0b58de943fcf42bd072af1e0b42 (diff) |
refactor: make AuthPromptHandler use the Hyper web server
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") -} |