diff options
Diffstat (limited to 'logic/src/login.rs')
-rw-r--r-- | logic/src/login.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/logic/src/login.rs b/logic/src/login.rs index 72a5903..5e255a0 100644 --- a/logic/src/login.rs +++ b/logic/src/login.rs @@ -3,19 +3,18 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin <metamuffin.org> */ -use crate::{CONF, session::create}; +use crate::{CONF, DATABASE, session::create}; use anyhow::{Result, anyhow}; use argon2::{Argon2, PasswordHasher, password_hash::Salt}; use jellycommon::user::UserPermission; -use jellydb::Database; use log::info; use std::{collections::HashSet, time::Duration}; -pub fn create_admin_account(database: &Database) -> Result<()> { +pub fn create_admin_account() -> Result<()> { if let Some(username) = &CONF.admin_username && let Some(password) = &CONF.admin_password { - database + DATABASE .create_admin_user(username, hash_password(username, password)) .unwrap(); } else { @@ -25,7 +24,6 @@ pub fn create_admin_account(database: &Database) -> Result<()> { } pub fn login_logic( - database: &Database, username: &str, password: &str, expire: Option<i64>, @@ -34,7 +32,7 @@ pub fn login_logic( // hashing the password regardless if the accounts exists to better resist timing attacks let password = hash_password(username, password); - let mut user = database + let mut user = DATABASE .get_user(username)? .ok_or(anyhow!("invalid password"))?; |