Update
This commit is contained in:
parent
8348aae593
commit
2435549298
12
src/main.rs
12
src/main.rs
@ -100,16 +100,24 @@ async fn sign_in(
|
|||||||
.set_ex(uid.to_string(), "1", 60 * 60 * 24) // session exists for 1 day
|
.set_ex(uid.to_string(), "1", 60 * 60 * 24) // session exists for 1 day
|
||||||
.await
|
.await
|
||||||
.expect("Failed to store session");
|
.expect("Failed to store session");
|
||||||
HttpResponse::Ok()
|
HttpResponse::SeeOther()
|
||||||
.cookie(
|
.cookie(
|
||||||
CookieBuilder::new("ses", uid.to_string())
|
CookieBuilder::new("ses", uid.to_string())
|
||||||
.secure(true)
|
.secure(true)
|
||||||
.max_age(Duration::hours(24))
|
.max_age(Duration::hours(24))
|
||||||
.finish(),
|
.finish(),
|
||||||
)
|
)
|
||||||
|
.append_header(("location", "/"))
|
||||||
.finish()
|
.finish()
|
||||||
} else {
|
} else {
|
||||||
HttpResponse::Ok().finish()
|
HttpResponse::BadRequest().body(
|
||||||
|
SignInForm {
|
||||||
|
login: payload.login,
|
||||||
|
not_found: true,
|
||||||
|
}
|
||||||
|
.render()
|
||||||
|
.unwrap_or_default(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user