begin authorization components implementation for gemini protocol

This commit is contained in:
yggverse 2024-11-16 12:55:30 +02:00
parent b32a1a297f
commit f487215ca9
8 changed files with 319 additions and 34 deletions

View file

@ -0,0 +1,37 @@
mod database;
use database::Database;
use sqlite::{Connection, Transaction};
use std::{rc::Rc, sync::RwLock};
/// API for `gemini_id` + `request` auth pairs operations
pub struct Auth {
pub database: Rc<Database>,
}
impl Auth {
// Constructors
/// Create new `Self`
pub fn new(connection: Rc<RwLock<Connection>>, profile_id: Rc<i64>) -> Self {
Self {
database: Rc::new(Database::new(connection, profile_id)),
}
}
}
// Tools
pub fn migrate(tx: &Transaction) -> Result<(), String> {
// Migrate self components
if let Err(e) = database::init(tx) {
return Err(e.to_string());
}
// Delegate migration to childs
// nothing yet..
// Success
Ok(())
}