auth and migration util

This commit is contained in:
realaravinth
2021-03-10 20:43:25 +05:30
parent e500a84c09
commit 328fe5ed3a
20 changed files with 3618 additions and 303 deletions

View File

@@ -15,7 +15,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
use actix::prelude::*;
use argon2_creds::{Config, ConfigBuilder, PasswordPolicy};
use m_captcha::{
cache::HashCache,
master::Master,
pow::ConfigBuilder as PoWConfigBuilder,
system::{System, SystemBuilder},
};
use sqlx::postgres::PgPoolOptions;
use sqlx::PgPool;
@@ -25,6 +32,7 @@ use crate::SETTINGS;
pub struct Data {
pub db: PgPool,
pub creds: Config,
pub captcha: System<HashCache>,
}
impl Data {
@@ -44,6 +52,20 @@ impl Data {
.build()
.unwrap();
Data { creds, db }
let master = Master::new().start();
let cache = HashCache::default().start();
let pow = PoWConfigBuilder::default()
.salt(SETTINGS.pow.salt.clone())
.build()
.unwrap();
let captcha = SystemBuilder::default()
.master(master)
.cache(cache)
.pow(pow)
.build()
.unwrap();
Data { creds, db, captcha }
}
}