Skip to content

Commit 6493118

Browse files
authored
Improve logout example (#496)
The current example for logout is not show a complete example. I have added a couple lines to handle the case where a logged out user tries to logout again.
1 parent 265b213 commit 6493118

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

actix-identity/src/lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ async fn login(request: HttpRequest) -> impl Responder {
7474
}
7575
7676
#[post("/logout")]
77-
async fn logout(user: Identity) -> impl Responder {
78-
user.logout();
77+
async fn logout(user: Option<Identity>) -> impl Responder {
78+
if let Some(user) = user {
79+
user.logout();
80+
}
7981
HttpResponse::Ok()
8082
}
8183
```

0 commit comments

Comments
 (0)