diff --git a/server/src/main.rs b/server/src/main.rs index 96b1619..a1cba70 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -38,9 +38,6 @@ pub fn rocket() -> rocket::Rocket { .mount("/invite", routes![ generate_invite, use_invite ]) - .mount("/user", routes![ - users::create_user - ]) .attach(Template::fairing()) .attach(DBConn::fairing()) } diff --git a/server/src/users.rs b/server/src/users.rs deleted file mode 100644 index 928e325..0000000 --- a/server/src/users.rs +++ /dev/null @@ -1,57 +0,0 @@ -use rocket::request::Form; -use rocket_contrib::json::Json; -use crate::payload; -// TODO: authentication needs to get applied basically everywhere but right now its missing - -#[derive(FromForm)] -pub struct NewUserForm { - pub username: String, - pub display: Option, - pub email: Option, // email users wants to use - pub password: String, // user provided password to use - pub token: String, // initially given to the user by the server - pub invite_id: u64 // invite that they used to join the server -} - -#[post("/create", data = "")] -pub fn create_user(user_sign_up: Form) -> Json { - // Constructing the response to the user with stuff they'll need to reconnect to the server - let email: String = match user_sign_up.email.clone() { - Some(mail) => { - mail - } - None => { - "None".to_string() - } - }; - // TODO: generate the token key-values that the client needs to reconnect easily from now on - let user_auth = payload::NewUserResponse { - userid: 1, - username: user_sign_up.username.clone(), - email: email - }; - - Json(user_auth) -} - -#[cfg(test)] -mod user_tests { - use super::*; - use rocket; - use rocket::local::Client; - use rocket::http::{Status, ContentType}; - - #[test] - fn new_user() { - let rocket = rocket::ignite() - .mount("/user", routes![create_user]); - let client = Client::new(rocket).expect("Invalid rocket instance"); - let response = client.post("/user/create") - .header(ContentType::Form) - .body("username=testuser&password=testpass") - .dispatch(); - - assert_eq!(response.status(), Status::Ok); - } - -}