diff --git a/src/api/v1/tests/auth.rs b/src/api/v1/tests/auth.rs
index 03014184..5bc1d300 100644
--- a/src/api/v1/tests/auth.rs
+++ b/src/api/v1/tests/auth.rs
@@ -89,21 +89,6 @@ async fn auth_works() {
)
.await;
- let resp = test::call_service(
- &mut app,
- post_request!(&creds, PAGES.auth.login).to_request(),
- )
- .await;
- assert_eq!(resp.status(), StatusCode::NOT_FOUND);
-
- creds.username = NAME.into();
- let resp = test::call_service(
- &mut app,
- post_request!(&creds, PAGES.auth.login).to_request(),
- )
- .await;
- assert_eq!(resp.status(), StatusCode::OK);
-
// 4. trying to signin with wrong password
creds.username = NAME.into();
creds.password = NAME.into();
diff --git a/src/pages/auth/login.rs b/src/pages/auth/login.rs
index 02da32a9..d759975a 100644
--- a/src/pages/auth/login.rs
+++ b/src/pages/auth/login.rs
@@ -15,37 +15,21 @@
* along with this program. If not, see .
*/
-use actix_identity::Identity;
-use actix_web::{web, HttpResponse, Responder};
+use actix_web::{HttpResponse, Responder};
use lazy_static::lazy_static;
use my_codegen::get;
use sailfish::TemplateOnce;
-use crate::api::v1::auth::runners;
-use crate::pages::errors::Errorable;
-use crate::AppData;
use crate::PAGES;
#[derive(Clone, TemplateOnce)]
#[template(path = "auth/login/index.html")]
-struct IndexPage {
- username: Option,
- password: Option,
- error: Option,
-}
-
-crate::ImplErrorable!(IndexPage);
-
+struct IndexPage;
const PAGE: &str = "Login";
impl Default for IndexPage {
fn default() -> Self {
- IndexPage {
- username: None,
- password: None,
- error: None,
- }
- }
+ IndexPage }
}
lazy_static! {
@@ -58,28 +42,3 @@ pub async fn login() -> impl Responder {
.content_type("text/html; charset=utf-8")
.body(&*INDEX)
}
-#[my_codegen::post(path = "PAGES.auth.login")]
-async fn login_post(
- id: Identity,
- payload: web::Json,
- data: AppData,
-) -> impl Responder {
- match runners::login_runner(&payload, &data).await {
- Ok(_) => {
- id.remember(payload.into_inner().username);
- HttpResponse::Ok().into()
- }
- Err(e) => {
- let payload = payload.into_inner();
- let username = Some(payload.username);
- let password = Some(payload.password);
-
- let page = IndexPage {
- username,
- password,
- ..Default::default()
- };
- page.get_error_resp(e)
- }
- }
-}
diff --git a/src/pages/auth/mod.rs b/src/pages/auth/mod.rs
index a758ac0b..fa7bb602 100644
--- a/src/pages/auth/mod.rs
+++ b/src/pages/auth/mod.rs
@@ -20,7 +20,6 @@ pub mod register;
pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
cfg.service(login::login);
- cfg.service(login::login_post);
cfg.service(register::join);
}
diff --git a/src/pages/errors.rs b/src/pages/errors.rs
index df72995a..9495c473 100644
--- a/src/pages/errors.rs
+++ b/src/pages/errors.rs
@@ -13,37 +13,12 @@
*
* You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */
-use actix_web::{error::ResponseError, web, HttpResponse, Responder};
+use actix_web::{web, HttpResponse, Responder};
use lazy_static::lazy_static;
use sailfish::TemplateOnce;
use crate::errors::PageError;
-pub trait Errorable: TemplateOnce {
- fn get_error_resp(self, e: E) -> HttpResponse;
-}
-
-#[macro_export]
-macro_rules! ImplErrorable {
- ($struct:ident) => {
- impl crate::pages::errors::Errorable for $struct {
- fn get_error_resp(mut self, e: E) -> actix_web::HttpResponse
- where
- E: actix_web::error::ResponseError + std::fmt::Display,
- //R: actix_web::Responder
- {
- self.error = Some(e.to_string());
- let page = self.render_once().unwrap();
- println!("status code: {}", e.status_code());
- actix_web::dev::HttpResponseBuilder::new(e.status_code())
- .content_type("text/html; charset=utf-8")
- .body(&page)
- .into()
- }
- }
- };
-}
-
#[derive(Clone, TemplateOnce)]
#[template(path = "errors/index.html")]
struct ErrorPage<'a> {