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

View File

@@ -29,6 +29,7 @@ use rauth::{
config::{Captcha, Config, EmailVerification, SMTPSettings, Template, Templates},
logic::Auth,
};
use revolt_quark::DatabaseInfo;
use std::str::FromStr;
use rocket_cors::AllowedOrigins;
/*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();
routes::mount(rocket)
.mount("/", rocket_cors::catch_all_options_routes())
//.mount("/auth/account", rauth::web::account::routes())
//.mount("/auth/session", rauth::web::session::routes())
//.manage(auth)
.mount("/auth/account", rauth::web::account::routes())
.mount("/auth/session", rauth::web::session::routes())
.manage(auth)
.manage(db)
.manage(cors.clone())
//.manage(RatelimitState::new())
.attach(cors)

View File

@@ -1,7 +1,7 @@
use revolt_quark::Result;
use revolt_quark::models::User;
use rocket::serde::json::{Json, Value};
use rocket::serde::json::Json;
#[get("/@me")]
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;
#[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!()
}