// trifid-api, an open source reimplementation of the Defined Networking nebula management server.
//     Copyright (C) 2023 c0repwn3r
//
//     This program is free software: you can redistribute it and/or modify
//     it under the terms of the GNU General Public License as published by
//     the Free Software Foundation, either version 3 of the License, or
//     (at your option) any later version.
//
//     This program is distributed in the hope that it will be useful,
//     but WITHOUT ANY WARRANTY; without even the implied warranty of
//     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//     GNU General Public License for more details.
//
//     You should have received a copy of the GNU General Public License
//     along with this program.  If not, see <https://www.gnu.org/licenses/>.

use rocket::{post, options};
use crate::auth::{PartialUserInfo, TOTPAuthenticatedUserInfo};

/*
These endpoints do not return any actual data, and are used purely to check auth tokens
by the client code.
Since PartialUserInfo implements FromRequest, and will error out the req even before
it gets to our handler if the auth is invalid, these reqs just have to have
it as a param. They therefore don't need to s
 */

#[options("/v1/auth/check_session")]
pub async fn options() -> &'static str {
    ""
}

#[post("/v1/auth/check_session")]
pub async fn check_session(_user: PartialUserInfo) -> &'static str {
    "ok"
}

#[options("/v1/auth/check_auth")]
pub async fn options_auth() -> &'static str {
    ""
}


#[post("/v1/auth/check_auth")]
pub async fn check_session_auth(_user: TOTPAuthenticatedUserInfo) -> &'static str {
    "ok"
}