mirror of
https://github.com/actix/actix-extras.git
synced 2025-01-22 06:45:56 +01: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:
parent
265b213123
commit
64931189c7
@ -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()
|
||||
}
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user