validate custom domain!
This commit is contained in:
		
							parent
							
								
									6072351840
								
							
						
					
					
						commit
						5e46922ed0
					
				
							
								
								
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							@ -1973,6 +1973,7 @@ dependencies = [
 | 
			
		||||
 "plume-api 0.3.0",
 | 
			
		||||
 "plume-common 0.3.0",
 | 
			
		||||
 "plume-models 0.3.0",
 | 
			
		||||
 "reqwest 0.9.19 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rocket 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rocket_contrib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
 | 
			
		||||
 "rocket_csrf 0.1.0 (git+https://github.com/fdb-hiroshima/rocket_csrf?rev=4a72ea2ec716cb0b26188fb00bccf2ef7d1e031c)",
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,7 @@ heck = "0.3.0"
 | 
			
		||||
lettre = { git = "https://github.com/lettre/lettre", rev = "c988b1760ad8179d9e7f3fb8594d2b86cf2a0a49" }
 | 
			
		||||
lettre_email = { git = "https://github.com/lettre/lettre", rev = "c988b1760ad8179d9e7f3fb8594d2b86cf2a0a49" }
 | 
			
		||||
num_cpus = "1.10"
 | 
			
		||||
reqwest = "0.9"
 | 
			
		||||
rocket = "0.4.0"
 | 
			
		||||
rocket_contrib = { version = "0.4.0", features = ["json"] }
 | 
			
		||||
rocket_i18n = { git = "https://github.com/Plume-org/rocket_i18n", rev = "e922afa7c366038b3433278c03b1456b346074f2" }
 | 
			
		||||
 | 
			
		||||
@ -22,6 +22,7 @@ extern crate num_cpus;
 | 
			
		||||
extern crate plume_api;
 | 
			
		||||
extern crate plume_common;
 | 
			
		||||
extern crate plume_models;
 | 
			
		||||
extern crate reqwest;
 | 
			
		||||
#[macro_use]
 | 
			
		||||
extern crate rocket;
 | 
			
		||||
extern crate rocket_contrib;
 | 
			
		||||
 | 
			
		||||
@ -19,6 +19,7 @@ use plume_models::{
 | 
			
		||||
    blog_authors::*, blogs::*, instance::Instance, medias::*, posts::Post, safe_string::SafeString,
 | 
			
		||||
    users::User, Connection, PlumeRocket,
 | 
			
		||||
};
 | 
			
		||||
use reqwest::Client;
 | 
			
		||||
use routes::{errors::ErrorPage, Page, RespondOrRedirect};
 | 
			
		||||
use template_utils::{IntoContext, Ructe};
 | 
			
		||||
 | 
			
		||||
@ -183,12 +184,17 @@ fn valid_domain(domain: &str, valid_domains: State<Mutex<HashMap<String, Instant
 | 
			
		||||
    let mutex = valid_domains.inner().lock();
 | 
			
		||||
    let mut validation_map = mutex.unwrap();
 | 
			
		||||
 | 
			
		||||
    let random_id = utils::random_hex();
 | 
			
		||||
    validation_map.insert(
 | 
			
		||||
        utils::random_hex(),
 | 
			
		||||
        random_id.clone(),
 | 
			
		||||
        Instant::now().checked_add(Duration::new(60, 0)).unwrap(),
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    true
 | 
			
		||||
    let client = Client::new();
 | 
			
		||||
    let validation_uri = format!("https://{}/domain_validation/{}", domain, random_id);
 | 
			
		||||
    let resp = client.get(&validation_uri).send();
 | 
			
		||||
 | 
			
		||||
    resp.unwrap().status().is_success()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[post("/blogs/new", data = "<form>")]
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user