use rocket::{http::Status, serde::json::Json};

use crate::json_result::JsonResult;

use self::session::ensure_session;

mod session;
pub mod users;

/// Tries to connect to the online classroom, and get a session cookie
#[get("/classroom/connect")]
pub async fn connection() -> (Status, Json<JsonResult<()>>) {
    match ensure_session().await {
        Ok(_) => (Status::Ok, JsonResult::ok(())),
        Err(err) => (Status::Ok, JsonResult::err(err)),
    }
}
