mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-26 02:19:22 +02:00
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.
This commit is contained in:
@ -74,8 +74,10 @@ async fn login(request: HttpRequest) -> impl Responder {
|
||||
}
|
||||
|
||||
#[post("/logout")]
|
||||
async fn logout(user: Identity) -> impl Responder {
|
||||
async fn logout(user: Option<Identity>) -> impl Responder {
|
||||
if let Some(user) = user {
|
||||
user.logout();
|
||||
}
|
||||
HttpResponse::Ok()
|
||||
}
|
||||
```
|
||||
|
Reference in New Issue
Block a user