use actix_identity::Identity; use actix_web::{HttpResponse, Responder, Result, get, web}; use crate::{app::App, storage::sql::user::User}; /// Check if you are logged in #[utoipa::path( responses( ( status = OK, description = "User login state checked", body = bool ) ) )] #[get("/is-logged-in")] pub(crate) async fn is_logged_in(user: Option) -> impl Responder { HttpResponse::Ok().json(user.is_some()) } /// Check if the server can be provisioned #[utoipa::path( responses( ( status = OK, description = "Provisioning state checked", body = bool ), ( status = INTERNAL_SERVER_ERROR, description = "Server encountered error", body = String ) ) )] #[get("/can-be-provisioned")] pub(crate) async fn can_be_provisioned(app: web::Data) -> Result { let users = User::get_all(&app).await?; Ok(HttpResponse::Ok().json(users.is_empty())) }