Start leave game form
Dependencies
- [2]
H7NQUYI6Record join to the game - [3]
6TPV5GQ3Show delegates in player table - [4]
WW3KRXX6Add page for reset game password - [5]
EVP2FSBHSplit index page - [6]
HZDCKIXQUse constants for templates - [7]
GUAEZDLEAdd turns info to slow game's page - [8]
LTQCLSBUSplit database usage in pages - [9]
DNFB7TNIAdd new pages and links to slow games and reset game password - [10]
NY766BOQAccept form to add player - [11]
AEWYJHUDStart to show player list - [12]
LOFH5LIAMake bold player name - [13]
WVHXYKCVAdd postgresql pools - [14]
TEB4R7OUAdd form to join game - [15]
A2LJT7TTShow duration in turns - [16]
XKG2L3QBShow label if player could join the game - [17]
OJO4B4QOAdd login form and empty handler - [18]
6NYILMKIAdd page for slow game - [*]
3HT5CE6SManage TTL duration in config - [*]
4MZ4VIR7Initial commit
Change contents
- edit in src/templates/slow-game.html at line 75
</fieldset></form>{{/if}}{{#if leave_data}}<form id="leave-game" action="lave-game.do" method="post"><fieldset><input name="csrf" type="hidden" value="{{ leave_data.csrf }}"><input name="submit" type="submit" value="Leave Game"> - replacement in src/pages/slow_game.rs at line 18
pub struct JoinData {pub struct JoinLeaveData { - replacement in src/pages/slow_game.rs at line 35
join_data: Option<JoinData>,join_data: Option<JoinLeaveData>,leave_data: Option<JoinLeaveData>, - replacement in src/pages/slow_game.rs at line 126
let (player_list, join_data) = if let Some(ref user) = user {let (player_list, join_data, leave_data) = if let Some(ref user) = user { - replacement in src/pages/slow_game.rs at line 161
Some(JoinData { csrf })Some(JoinLeaveData { csrf }) - replacement in src/pages/slow_game.rs at line 166
(Some(users), join_data)(Some(users), join_data, None) - replacement in src/pages/slow_game.rs at line 168
(None, None)(None, None, None) - edit in src/pages/slow_game.rs at line 187
leave_data, - replacement in src/pages/slow_game.rs at line 201
form: web::Form<JoinData>,form: web::Form<JoinLeaveData>, - edit in src/pages/slow_game.rs at line 257
}HttpResponse::Found().append_header((header::LOCATION,format!("slow-game-{}.html", cached_data.0),)).finish()}pub async fn post_leave_game(request: HttpRequest,form: web::Form<JoinLeaveData>,data: web::Data<WebData<'_>>,_data_rw: web::Data<DataBaseRw>,) -> HttpResponse {let cached_data = {let mut cache = data.cache_leave_game.lock().await;cache.remove(&form.csrf)};let cached_data = if let Some(cd) = cached_data {cd} else {log::warn!("Unknown data for CSRF: {}", form.csrf);return HttpResponse::BadRequest().body("Incorrect");};let jar = request_to_jar(request);if jar.private(&data.cookies_key).get("auth").map_or(true, |x| x.value().to_lowercase() != cached_data.1){log::warn!("Incorrect user");return HttpResponse::BadRequest().body("Incorrect"); - edit in src/pages/mod.rs at line 48
pub cache_leave_game: Mutex<TtlCache<Uuid, (String, String)>>, - replacement in src/main.rs at line 22
use pages::slow_game::{post_join_game, slow_game};use pages::slow_game::{post_join_game, post_leave_game, slow_game}; - edit in src/main.rs at line 219
cache_leave_game: tokio::sync::Mutex::new(ttl_cache::TtlCache::new(cache_capacity)), - edit in src/main.rs at line 269
.route("/leave-game.do", web::post().to(post_leave_game))