diff --git a/src/main.rs b/src/main.rs index 9b75628..3b3c85e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,7 +16,7 @@ use tracing::{info, metadata::LevelFilter}; use crate::routes::{ auth::{authenticate, validate, refresh}, - session::{join, has_joined_wrapper, profile}, + session::{join, has_joined_wrapper, profile}, register::register_unmigrated, }; /// Reimplementation of legacy auth server for minecraft @@ -83,7 +83,7 @@ async fn main() -> Result<(), Box> { .route("/session/minecraft/hasJoined", get(has_joined_wrapper)) .route("/session/minecraft/profile/:user_id", get(profile)) // CUSTOM - .route("/register", post(register_tmp)) + .route("/register/unmigrated", post(register_unmigrated)) .fallback(fallback_route) .with_state(AppState { store, db, cfg }); @@ -105,15 +105,3 @@ async fn fallback_route() -> impl IntoResponse { (StatusCode::OK, Json(error)) } - -async fn register_tmp(State(state): State, Json(payload): Json) -> StatusCode { - let user = entities::user::ActiveModel { - id: NotSet, - name: Set(payload.user), - password: Set(payload.password), - uuid: Set(Uuid::new_v4()), - }; - entities::user::Entity::insert(user).exec(&state.db).await.unwrap(); - - StatusCode::OK -} diff --git a/src/proto.rs b/src/proto.rs index ab5ab62..3de30ca 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -134,11 +134,21 @@ pub struct JoinResponse { pub properties: Vec, } +#[derive(Serialize, Deserialize, Debug)] +pub struct AccessToken { + pub accessToken: String, + pub clientToken: String, + pub selectedProfile: Profile, + pub availableProfiles: Option>, +} - - -#[derive(Serialize, Deserialize)] +#[derive(Serialize, Deserialize, Debug)] pub struct RegisterRequest { - pub user: String, + pub token: AccessToken, pub password: String, } + +#[derive(Serialize, Deserialize)] +pub struct RegisterResponse { + pub user: Profile +} diff --git a/src/routes/mod.rs b/src/routes/mod.rs index f373eb7..7c831c4 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,2 +1,3 @@ pub mod auth; pub mod session; +pub mod register;