diff --git a/README.md b/README.md index 2eb4199..9a7a990 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,9 @@ Rough roadmap in a rough order of priority * [ ] Individual email actions * [ ] SSO Support (openid) * [x] Basic implementation - * [x] User mapping - * [x] User creation + * [ ] User mapping + * [ ] User creation * [ ] User logout -* [ ] Normal user registration (email/username+pass) * [ ] S3 backend support * [ ] Administration panel * [ ] Add storage backends diff --git a/src/main.rs b/src/main.rs index fbbc871..7fc2d41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -131,7 +131,6 @@ async fn rocket() -> _ { .manage(libraries_manager) .manage(settings) .manage(sso) - .manage(users) .attach(store.fairing()) .attach(Template::custom(|engines| { diff --git a/src/managers/libraries.rs b/src/managers/libraries.rs index d7cb8e6..aa7d50a 100644 --- a/src/managers/libraries.rs +++ b/src/managers/libraries.rs @@ -1,10 +1,9 @@ use std::collections::HashMap; -use sqlx::{query_as, Pool, Postgres}; +use sqlx::{Pool, Postgres}; use tokio::sync::RwLock; use crate::objs::library::Library; use crate::managers::repos::{RepoContainer, RepoManager}; use crate::models; -use crate::models::library::LibraryModel; use crate::util::{JsonErrorResponse, ResponseError}; pub struct LibraryManager { @@ -20,13 +19,6 @@ impl LibraryManager { } } - pub async fn list(&self, user_id: &str) -> Result, anyhow::Error> { - // TODO: check for access from library_permissions - let libraries = query_as!(LibraryModel, "SELECT * FROM storage.libraries WHERE owner_id = $1", user_id) - .fetch_all(&self.pool) - .await.map_err(anyhow::Error::from)?; - Ok(libraries) - } pub async fn get(&self, library_id: &str) -> Result { let Some(library) = models::library::get_library(&self.pool, library_id).await .map_err(|e| ResponseError::GenericError)? else { diff --git a/src/models/library.rs b/src/models/library.rs index f724408..c251e32 100644 --- a/src/models/library.rs +++ b/src/models/library.rs @@ -26,12 +26,6 @@ pub struct LibraryWithRepoModel { pub storage_type: String, } -pub enum PermissionLevel { - ReadOnly = 0, - ReadWrite = 1, - Admin = 2 -} - pub async fn get_library(pool: &DB, library_id: &str) -> Result, anyhow::Error> { let library_id = Uuid::from_str(library_id)?; let library = query_as!(LibraryModel, "select * from storage.libraries where id = $1", library_id) diff --git a/src/routes/ui/user.rs b/src/routes/ui/user.rs index b98cfcb..70ff74f 100644 --- a/src/routes/ui/user.rs +++ b/src/routes/ui/user.rs @@ -17,7 +17,6 @@ use tokio::sync::Mutex; use crate::consts::FILE_CONSTANTS; use crate::guards::{AuthUser}; use crate::managers::libraries::LibraryManager; -use crate::managers::user::UsersState; use crate::objs::library::ListOptions; use crate::routes::ui::auth; use crate::util::{JsonErrorResponse, ResponseError}; @@ -27,10 +26,8 @@ pub async fn user_settings(user: AuthUser, route: &Route) -> Template { Template::render("settings", context! { session: user.session, route: route.uri.path() }) } #[get("/")] -pub async fn index(user: AuthUser, libraries: &State>>, route: &Route) -> Template { - let libraries = libraries.lock().await; - let list = libraries.list(&user.session.user.id).await.unwrap(); - Template::render("index", context! { session: user.session, libraries: list, route: route.uri.path(), test: "value" }) +pub async fn index(user: AuthUser, route: &Route) -> Template { + Template::render("index", context! { session: user.session, route: route.uri.path(), test: "value" }) } #[get("/library/")] diff --git a/templates/index.html.hbs b/templates/index.html.hbs index cced765..23c9dc8 100644 --- a/templates/index.html.hbs +++ b/templates/index.html.hbs @@ -16,20 +16,20 @@ Name - Created + Size + Last Updated Owner - {{#each libraries}} - {{name}} + My Library - {{ created_at }} - {{ owner_id }} + + + Me - {{/each}}