fix: join request sends just the uuid
This commit is contained in:
parent
7e9cafa110
commit
0b19c94acf
2 changed files with 5 additions and 5 deletions
|
@ -96,7 +96,7 @@ pub struct SignoutRequest {
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct JoinRequest {
|
pub struct JoinRequest {
|
||||||
pub accessToken: String,
|
pub accessToken: String,
|
||||||
pub selectedProfile: Profile,
|
pub selectedProfile: Uuid,
|
||||||
pub serverId: String,
|
pub serverId: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::{AppState, proto, JoinAttempt, entities};
|
||||||
|
|
||||||
pub async fn join(State(state): State<AppState>, Json(payload): Json<proto::JoinRequest>) -> StatusCode {
|
pub async fn join(State(state): State<AppState>, Json(payload): Json<proto::JoinRequest>) -> StatusCode {
|
||||||
let user = entities::user::Entity::find().filter(
|
let user = entities::user::Entity::find().filter(
|
||||||
entities::user::Column::Uuid.eq(payload.selectedProfile.id)
|
entities::user::Column::Uuid.eq(payload.selectedProfile)
|
||||||
).one(&state.db).await.unwrap().unwrap();
|
).one(&state.db).await.unwrap().unwrap();
|
||||||
|
|
||||||
let tokens = entities::token::Entity::find().filter(
|
let tokens = entities::token::Entity::find().filter(
|
||||||
|
@ -19,11 +19,11 @@ pub async fn join(State(state): State<AppState>, Json(payload): Json<proto::Join
|
||||||
).all(&state.db).await.unwrap();
|
).all(&state.db).await.unwrap();
|
||||||
|
|
||||||
if tokens.iter().any(|x| x.access_token == payload.accessToken) {
|
if tokens.iter().any(|x| x.access_token == payload.accessToken) {
|
||||||
state.store.lock().await.insert(payload.selectedProfile.id, JoinAttempt::new(payload.serverId.clone()));
|
state.store.lock().await.insert(payload.selectedProfile, JoinAttempt::new(payload.serverId.clone()));
|
||||||
info!(target: "JOIN", "user {} has joined server {}", payload.selectedProfile.name, payload.serverId);
|
info!(target: "SESSION", "[JOIN] user {} has joined server {}", payload.selectedProfile, payload.serverId);
|
||||||
StatusCode::OK
|
StatusCode::OK
|
||||||
} else {
|
} else {
|
||||||
warn!(target: "JOIN", "user {} attempted to join server {} without a valid token", payload.selectedProfile.name, payload.serverId);
|
warn!(target: "SESSION", "[JOIN] user {} attempted to join server {} without a valid token ({})", payload.selectedProfile, payload.serverId, payload.accessToken);
|
||||||
StatusCode::UNAUTHORIZED
|
StatusCode::UNAUTHORIZED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue