feat(routes/users): implement fetch_self

This commit is contained in:
Paul Makles
2022-01-31 20:07:36 +00:00
parent c39a9917df
commit c1cd4bfa66
4 changed files with 17 additions and 7 deletions

2
Cargo.lock generated
View File

@@ -3017,6 +3017,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"async-std", "async-std",
"async-trait", "async-trait",
"bitfield",
"impl_ops", "impl_ops",
"lazy_static", "lazy_static",
"log", "log",
@@ -3024,6 +3025,7 @@ dependencies = [
"num_enum", "num_enum",
"ops", "ops",
"optional_struct", "optional_struct",
"rauth",
"rocket", "rocket",
"serde", "serde",
"validator 0.14.0", "validator 0.14.0",

View File

@@ -29,6 +29,7 @@ use rauth::{
config::{Captcha, Config, EmailVerification, SMTPSettings, Template, Templates}, config::{Captcha, Config, EmailVerification, SMTPSettings, Template, Templates},
logic::Auth, logic::Auth,
}; };
use revolt_quark::DatabaseInfo;
use std::str::FromStr; use std::str::FromStr;
use rocket_cors::AllowedOrigins; use rocket_cors::AllowedOrigins;
/*use util::variables::{ /*use util::variables::{
@@ -128,13 +129,20 @@ async fn launch_web() {
}; };
}*/ }*/
//let auth = Auth::new(database::get_db(), config); let db = DatabaseInfo::Dummy.connect().await.unwrap();
let mongo_db = mongodb::Client::with_uri_str("mongodb://localhost")
.await
.expect("Failed to init db connection.");
let auth = Auth::new(mongo_db.database("revolt"), config);
let rocket = rocket::build(); let rocket = rocket::build();
routes::mount(rocket) routes::mount(rocket)
.mount("/", rocket_cors::catch_all_options_routes()) .mount("/", rocket_cors::catch_all_options_routes())
//.mount("/auth/account", rauth::web::account::routes()) .mount("/auth/account", rauth::web::account::routes())
//.mount("/auth/session", rauth::web::session::routes()) .mount("/auth/session", rauth::web::session::routes())
//.manage(auth) .manage(auth)
.manage(db)
.manage(cors.clone()) .manage(cors.clone())
//.manage(RatelimitState::new()) //.manage(RatelimitState::new())
.attach(cors) .attach(cors)

View File

@@ -1,7 +1,7 @@
use revolt_quark::Result; use revolt_quark::Result;
use revolt_quark::models::User; use revolt_quark::models::User;
use rocket::serde::json::{Json, Value}; use rocket::serde::json::Json;
#[get("/@me")] #[get("/@me")]
pub async fn req(user: User) -> Result<Json<User>> { pub async fn req(user: User) -> Result<Json<User>> {

View File

@@ -1,8 +1,8 @@
use revolt_quark::{Error, Result}; use revolt_quark::{Ref, Result, models::User};
use rocket::serde::json::Value; use rocket::serde::json::Value;
#[get("/<target>")] #[get("/<target>")]
pub async fn req(user: User, target: User, target: String) -> Result<Value> { pub async fn req(user: User, target: Ref) -> Result<Value> {
todo!() todo!()
} }