removing users module for now because invites are getting reworked
a lot of structural changes are coming to how users are dealt with
This commit is contained in:
parent
0a587da14c
commit
3a995fa469
@ -38,9 +38,6 @@ pub fn rocket() -> rocket::Rocket {
|
|||||||
.mount("/invite", routes![
|
.mount("/invite", routes![
|
||||||
generate_invite, use_invite
|
generate_invite, use_invite
|
||||||
])
|
])
|
||||||
.mount("/user", routes![
|
|
||||||
users::create_user
|
|
||||||
])
|
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
.attach(DBConn::fairing())
|
.attach(DBConn::fairing())
|
||||||
}
|
}
|
||||||
|
@ -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<String>,
|
|
||||||
pub email: Option<String>, // 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 = "<user_sign_up>")]
|
|
||||||
pub fn create_user(user_sign_up: Form<NewUserForm>) -> Json<payload::NewUserResponse> {
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user