feat & fix: load verify routes and fix template loads

This commit is contained in:
Aravinth Manivannan 2022-05-19 19:32:10 +05:30
parent 0fe3c8f619
commit 083af27351
2 changed files with 8 additions and 6 deletions

View file

@ -29,4 +29,5 @@ pub fn register_templates(t: &mut tera::Tera) {
pub fn services(cfg: &mut actix_web::web::ServiceConfig) { pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
add::services(cfg); add::services(cfg);
verify::services(cfg);
} }

View file

@ -35,7 +35,6 @@ use crate::*;
pub use crate::pages::*; pub use crate::pages::*;
pub const TITLE: &str = "Setup spidering"; pub const TITLE: &str = "Setup spidering";
pub const AUTH_ADD: TemplateFile = TemplateFile::new("auth_add", "pages/auth/add.html");
pub const AUTH_CHALLENGE: TemplateFile = pub const AUTH_CHALLENGE: TemplateFile =
TemplateFile::new("auth_challenge", "pages/auth/challenge.html"); TemplateFile::new("auth_challenge", "pages/auth/challenge.html");
@ -66,7 +65,9 @@ impl VerifyChallenge {
} }
pub fn render(&self) -> String { pub fn render(&self) -> String {
TEMPLATES.render(AUTH_ADD.name, &self.ctx.borrow()).unwrap() TEMPLATES
.render(AUTH_CHALLENGE.name, &self.ctx.borrow())
.unwrap()
} }
pub fn page(s: &Settings, payload: &Challenge) -> String { pub fn page(s: &Settings, payload: &Challenge) -> String {
@ -76,7 +77,7 @@ impl VerifyChallenge {
} }
#[get(path = "PAGES.auth.verify")] #[get(path = "PAGES.auth.verify")]
pub async fn get_add( pub async fn get_verify(
ctx: WebCtx, ctx: WebCtx,
db: WebDB, db: WebDB,
query: web::Query<VerifyChallengePayload>, query: web::Query<VerifyChallengePayload>,
@ -98,8 +99,8 @@ pub async fn get_add(
} }
pub fn services(cfg: &mut web::ServiceConfig) { pub fn services(cfg: &mut web::ServiceConfig) {
cfg.service(get_add); cfg.service(get_verify);
cfg.service(add_submit); cfg.service(submit_verify);
} }
async fn _get_challenge( async fn _get_challenge(
@ -112,7 +113,7 @@ async fn _get_challenge(
} }
#[post(path = "PAGES.auth.verify")] #[post(path = "PAGES.auth.verify")]
pub async fn add_submit( pub async fn submit_verify(
payload: web::Form<VerifyChallengePayload>, payload: web::Form<VerifyChallengePayload>,
ctx: WebCtx, ctx: WebCtx,
db: WebDB, db: WebDB,