auth: Add a logout button

Add a logout button that clears the auth cookies, logging out the user.
It also tries to remove the auth token from the databse, but will ignore
any error during the database operation.

Do some include clean-ups as well.
This commit is contained in:
trotFunky 2024-07-26 20:32:14 +01:00
parent 36be6b51ae
commit c4e252dbc2
4 changed files with 33 additions and 11 deletions

View file

@ -1,18 +1,13 @@
#[macro_use] extern crate rocket;
use rocket::{Rocket, Build, futures};
use rocket::fs::{FileServer, relative};
use rocket::http::CookieJar;
use rocket::response::Redirect;
use rocket::serde::{Serialize, Deserialize, json::Json};
use rocket_dyn_templates::{Template, context};
use rocket_dyn_templates::Template;
use rocket_db_pools::{sqlx, sqlx::Row, Database, Connection};
use sqlx::Error;
use rocket_db_pools::{sqlx, sqlx::Row, Connection};
mod auth;
use auth::User;
mod truth;
mod vote;
@ -21,7 +16,6 @@ mod week;
mod database;
mod database_records;
use database_records::*;
use database::Db;
#[get("/")]
@ -46,7 +40,7 @@ fn rocket() -> _ {
vote::fetch_vote_data, vote::vote,
truth::create_truth, truth::edit_truth,
week::week, week::update_week, week::set_last_week, week::create_week,
auth::login])
auth::login, auth::logout])
.attach(database::stage())
.attach(Template::fairing())
}