blob: 31cbfa53abc7dc9664399fc58f799c4233b85b02 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
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<Identity>) -> 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<App>) -> Result<impl Responder> {
let users = User::get_all(&app).await?;
Ok(HttpResponse::Ok().json(users.is_empty()))
}
|