responsive navbar

This commit is contained in:
realaravinth
2021-07-01 22:36:22 +05:30
parent 362e2aeae0
commit 43d970980f
13 changed files with 203 additions and 39 deletions

View File

@@ -16,6 +16,7 @@
*/
//! App data: redis cache, database connections, etc.
use std::sync::Arc;
use std::thread;
use actix::prelude::*;
use argon2_creds::{Config, ConfigBuilder, PasswordPolicy};
@@ -145,12 +146,6 @@ impl Data {
#[cfg(not(tarpaulin_include))]
/// create new instance of app data
pub async fn new() -> Arc<Self> {
let db = PgPoolOptions::new()
.max_connections(SETTINGS.database.pool)
.connect(&SETTINGS.database.url)
.await
.expect("Unable to form database pool");
let creds = ConfigBuilder::default()
.username_case_mapped(true)
.profanity(true)
@@ -159,9 +154,19 @@ impl Data {
.build()
.unwrap();
log::info!("Initializing credential manager");
//creds.init();
log::info!("Initialized credential manager");
let c = creds.clone();
let init = thread::spawn(move || {
log::info!("Initializing credential manager");
c.init();
log::info!("Initialized credential manager");
});
let db = PgPoolOptions::new()
.max_connections(SETTINGS.database.pool)
.connect(&SETTINGS.database.url)
.await
.expect("Unable to form database pool");
let data = Data {
creds,
@@ -170,6 +175,8 @@ impl Data {
mailer: Self::get_mailer(),
};
init.join().unwrap();
Arc::new(data)
}

View File

@@ -112,7 +112,8 @@ mod tests {
.unwrap();
let client = Client::default();
let mut resp = client.get("http://localhost:1080/email")
let mut resp = client
.get("http://localhost:1080/email")
.send()
.await
.unwrap();
@@ -120,7 +121,8 @@ mod tests {
let data = &data[0];
let smtp = SETTINGS.smtp.as_ref().unwrap();
let from_addr = &data["headers"]["from"];["address"];
let from_addr = &data["headers"]["from"];
["address"];
assert!(from_addr.to_string().contains(&smtp.from));

View File

@@ -0,0 +1,51 @@
/*
* Copyright (C) 2021 Aravinth Manivannan <realaravinth@batsense.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! Email operations: verification, notification, etc
use lettre::{
message::{header, MultiPart, SinglePart},
AsyncTransport, Message,
};
use sailfish::TemplateOnce;
use crate::errors::*;
use crate::Data;
use crate::SETTINGS;
const PAGE: &str = "Login";
#[derive(Clone, Default, TemplateOnce)]
#[template(path = "auth/email-verification/index.html")]
struct IndexPage {
email: String,
}
lazy_static! {
static ref INDEX: String = IndexPage::default().render_once().unwrap();
}
#[get(path = "PAGES.auth.login")]
pub async fn email_verification() -> impl Responder {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(&*INDEX)
}
//TODO
// Design cookie system to handle registration to showing this page,
// verifying email and discarding the cookie