Set language cookie even when connected + increase number of concurrent connections when sign in and sign up
This commit is contained in:
parent
b40ee5f765
commit
a90c097e2a
5 changed files with 94 additions and 93 deletions
|
|
@ -18,7 +18,7 @@ pub const TOKEN_SIZE: usize = 32;
|
|||
|
||||
pub const SEND_EMAIL_TIMEOUT: Duration = Duration::from_secs(60);
|
||||
|
||||
pub const NUMBER_OF_CONCURRENT_HTTP_REQUEST_FOR_RATE_LIMIT: u64 = 5;
|
||||
pub const NUMBER_OF_CONCURRENT_HTTP_REQUEST_FOR_RATE_LIMIT: u64 = 20;
|
||||
pub const DURATION_FOR_RATE_LIMIT: Duration = Duration::from_secs(5);
|
||||
|
||||
// HTTP headers, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use axum::Error;
|
||||
use chrono::{Duration, prelude::*};
|
||||
use rand::distr::{Alphanumeric, SampleString};
|
||||
use sqlx::Sqlite;
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ pub async fn set_lang(
|
|||
let mut jar = CookieJar::from_headers(&headers);
|
||||
if let Some(user) = user {
|
||||
connection.set_user_lang(user.id, &ron.lang).await?;
|
||||
} else {
|
||||
let cookie = Cookie::build((consts::COOKIE_LANG_NAME, ron.lang)).path("/");
|
||||
jar = jar.add(cookie);
|
||||
}
|
||||
|
||||
// Always set the cookie even is the user is connected in case of disconnection.
|
||||
let cookie = Cookie::build((consts::COOKIE_LANG_NAME, ron.lang)).path("/");
|
||||
jar = jar.add(cookie);
|
||||
|
||||
Ok((jar, StatusCode::OK))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue