summaryrefslogtreecommitdiff
path: root/src/login/routes/logout
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-10-22 23:25:24 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-10-22 23:25:24 -0400
commit01f9f3549c76702fd56e58d44c5180fecddb4bfa (patch)
treee7a64e70975a8b50bc442d28c17161b82c42c63a /src/login/routes/logout
parent214a9e6c1fd729fc2c49eb2a5d41b5651ff5bc61 (diff)
Sort out the naming of the various parts of an identity.
* A `cookie::Identity` (`IdentityCookie`) is a specialized CookieJar for working with identities. * An `Identity` is a token/login pair. I hope for this to be a bit more legible. In service of this, `Login` is no longer extractable. You have to get an identity.
Diffstat (limited to 'src/login/routes/logout')
-rw-r--r--src/login/routes/logout/post.rs6
-rw-r--r--src/login/routes/logout/test.rs14
2 files changed, 10 insertions, 10 deletions
diff --git a/src/login/routes/logout/post.rs b/src/login/routes/logout/post.rs
index 6b7a62a..bb09b9f 100644
--- a/src/login/routes/logout/post.rs
+++ b/src/login/routes/logout/post.rs
@@ -8,15 +8,15 @@ use crate::{
app::App,
clock::RequestedAt,
error::{Internal, Unauthorized},
- token::{app, extract::IdentityToken},
+ token::{app, extract::IdentityCookie},
};
pub async fn handler(
State(app): State<App>,
RequestedAt(now): RequestedAt,
- identity: IdentityToken,
+ identity: IdentityCookie,
Json(_): Json<Request>,
-) -> Result<(IdentityToken, StatusCode), Error> {
+) -> Result<(IdentityCookie, StatusCode), Error> {
if let Some(secret) = identity.secret() {
let (token, _) = app.tokens().validate(&secret, &now).await?;
app.tokens().logout(&token).await?;
diff --git a/src/login/routes/logout/test.rs b/src/login/routes/logout/test.rs
index 91837fe..775fa9f 100644
--- a/src/login/routes/logout/test.rs
+++ b/src/login/routes/logout/test.rs
@@ -12,9 +12,9 @@ async fn successful() {
let app = fixtures::scratch_app().await;
let now = fixtures::now();
- let login = fixtures::login::create_with_password(&app, &fixtures::now()).await;
- let identity = fixtures::identity::logged_in(&app, &login, &now).await;
- let secret = fixtures::identity::secret(&identity);
+ let creds = fixtures::login::create_with_password(&app, &fixtures::now()).await;
+ let identity = fixtures::cookie::logged_in(&app, &creds, &now).await;
+ let secret = fixtures::cookie::secret(&identity);
// Call the endpoint
@@ -49,10 +49,10 @@ async fn no_identity() {
// Call the endpoint
- let identity = fixtures::identity::not_logged_in();
+ let identity = fixtures::cookie::not_logged_in();
let (identity, status) = post::handler(State(app), fixtures::now(), identity, Json::default())
.await
- .expect("logged out with no token");
+ .expect("logged out with no token succeeds");
// Verify the return value's basic structure
@@ -68,10 +68,10 @@ async fn invalid_token() {
// Call the endpoint
- let identity = fixtures::identity::fictitious();
+ let identity = fixtures::cookie::fictitious();
let post::Error(error) = post::handler(State(app), fixtures::now(), identity, Json::default())
.await
- .expect_err("logged out with an invalid token");
+ .expect_err("logged out with an invalid token fails");
// Verify the return value's basic structure