Add log-out route (necessary to delete secret cookie)

This commit is contained in:
D. Scott Boggs 2023-08-26 05:47:38 -04:00
parent a8e4e5145b
commit f6fb736ff7
2 changed files with 7 additions and 1 deletions

View file

@ -69,6 +69,12 @@ pub(super) async fn sign_up(
Ok(())
}
#[delete("/")]
pub(super) async fn sign_out(cookies: &CookieJar<'_>) {
cookies.remove_private(Cookie::named("user"));
cookies.remove(Cookie::named("name"));
}
/// Authentication guard
#[derive(Deref)]
pub(super) struct Auth(users::Model);

View file

@ -114,7 +114,7 @@ pub fn start_server(db: DatabaseConnection) -> Rocket<Build> {
"/api/v1/groups",
routes![all_groups, group, insert_group, update_group, delete_group],
)
.mount("/api/v1/auth", routes![auth::login, auth::sign_up])
.mount("/api/v1/auth", routes![auth::login, auth::sign_up, auth::sign_out])
.mount("/", FileServer::from("/src/public"));
#[cfg(feature = "unsafe_import")]