1
0
Fork 0
forked from TWS/kalkutago

Compare commits

..

11 commits

Author SHA1 Message Date
D. Scott Boggs
f6fb736ff7 Add log-out route (necessary to delete secret cookie) 2023-08-26 06:09:04 -04:00
D. Scott Boggs
a8e4e5145b add tests 2023-08-26 06:09:04 -04:00
D. Scott Boggs
1c400e7ffa Remove no-longer-existing Rust feature default_free_fn 2023-08-26 06:09:04 -04:00
D. Scott Boggs
d7285a84bb Fix authenticated track insertion 2023-08-26 06:09:04 -04:00
D. Scott Boggs
205a3b165e Rename user -> users 2023-08-26 06:09:04 -04:00
D. Scott Boggs
f44f15d2b6 tracks are now relative to an authenticated user 2023-08-26 06:09:04 -04:00
D. Scott Boggs
46a9374571 Add entity and relations for user-tracks relationship 2023-08-26 06:09:04 -04:00
D. Scott Boggs
05bda8deb0 Add users-to-tracks many-to-many association 2023-08-26 06:09:04 -04:00
D. Scott Boggs
2485740291 Add login+sign_up routes and auth guard 2023-08-26 06:09:04 -04:00
D. Scott Boggs
792779a36d Add support for rocket's "secret cookies" 2023-08-26 06:09:04 -04:00
D. Scott Boggs
0a197db93f Add user model 2023-08-26 06:09:04 -04:00
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")]