mirror of
https://github.com/actix/examples
synced 2025-01-22 14:05:55 +01:00
Update session/cookie-auth to v4 (#492)
Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
parent
ff0a06e019
commit
85d1503ac2
@ -4,7 +4,7 @@ version = "1.0.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "3"
|
actix-web = "4.0.0-beta.21"
|
||||||
actix-identity = "0.3"
|
actix-identity = "0.4.0-beta.8"
|
||||||
env_logger = "0.8"
|
env_logger = "0.9.0"
|
||||||
rand = "0.7"
|
rand = "0.8.4"
|
||||||
|
@ -12,12 +12,16 @@ async fn index(id: Identity) -> String {
|
|||||||
|
|
||||||
async fn login(id: Identity) -> HttpResponse {
|
async fn login(id: Identity) -> HttpResponse {
|
||||||
id.remember("user1".to_owned());
|
id.remember("user1".to_owned());
|
||||||
HttpResponse::Found().header("location", "/").finish()
|
HttpResponse::Found()
|
||||||
|
.insert_header(("location", "/"))
|
||||||
|
.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn logout(id: Identity) -> HttpResponse {
|
async fn logout(id: Identity) -> HttpResponse {
|
||||||
id.forget();
|
id.forget();
|
||||||
HttpResponse::Found().header("location", "/").finish()
|
HttpResponse::Found()
|
||||||
|
.insert_header(("location", "/"))
|
||||||
|
.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user