From 13f7734751a204d2c793b92c8e6c18e872bf5713 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Wed, 12 Jan 2022 08:40:20 +0900 Subject: [PATCH] Hide email sign-up routings when it's disabled --- src/routes/email_signups.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/routes/email_signups.rs b/src/routes/email_signups.rs index 057a8d5c..0b93bb1a 100644 --- a/src/routes/email_signups.rs +++ b/src/routes/email_signups.rs @@ -4,8 +4,12 @@ use crate::{ template_utils::{IntoContext, Ructe}, }; use plume_models::{ - db_conn::DbConn, email_signups::EmailSignup, instance::Instance, lettre::Transport, - signups::Strategy as SignupStrategy, Error, PlumeRocket, CONFIG, + db_conn::DbConn, + email_signups::EmailSignup, + instance::Instance, + lettre::Transport, + signups::{self, Strategy as SignupStrategy}, + Error, PlumeRocket, CONFIG, }; use rocket::{ http::Status, @@ -69,6 +73,7 @@ pub fn create( form: LenientForm, conn: DbConn, rockets: PlumeRocket, + _enabled: signups::Email, ) -> Result { if !matches!(CONFIG.signup, SignupStrategy::Email) { return Ok(Flash::error( @@ -138,12 +143,17 @@ pub fn create( } #[get("/email_signups/new")] -pub fn created(conn: DbConn, rockets: PlumeRocket) -> Ructe { +pub fn created(conn: DbConn, rockets: PlumeRocket, _enabled: signups::Email) -> Ructe { render!(email_signups::create(&(&conn, &rockets).to_context())) } #[get("/email_signups/")] -pub fn show(token: String, conn: DbConn, rockets: PlumeRocket) -> Result { +pub fn show( + token: String, + conn: DbConn, + rockets: PlumeRocket, + _enabled: signups::Email, +) -> Result { let signup = EmailSignup::find_by_token(&conn, token.into())?; let confirmation = signup.confirm(&conn); if let Some(err) = confirmation.err() { @@ -179,6 +189,7 @@ pub fn signup( form: LenientForm, conn: DbConn, rockets: PlumeRocket, + _enabled: signups::Email, ) -> Result { use RespondOrRedirect::{FlashRedirect, Response};