mirror of
https://github.com/stoatchat/stoatchat.git
synced 2026-07-14 13:36:59 +00:00
Migrate the rest of the code.
This commit is contained in:
@@ -2,7 +2,6 @@ use crate::database::*;
|
||||
use crate::util::result::{Error, Result};
|
||||
|
||||
use mongodb::bson::{doc, from_document};
|
||||
use rocket::http::RawStr;
|
||||
use rocket::request::FromParam;
|
||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
@@ -127,9 +126,9 @@ impl User {
|
||||
}
|
||||
|
||||
impl<'r> FromParam<'r> for Ref {
|
||||
type Error = &'r RawStr;
|
||||
type Error = &'r str;
|
||||
|
||||
fn from_param(param: &'r RawStr) -> Result<Self, Self::Error> {
|
||||
fn from_param(param: &'r str) -> Result<Self, Self::Error> {
|
||||
if let Ok(result) = Ref::from(param.to_string()) {
|
||||
if result.validate().is_ok() {
|
||||
return Ok(result);
|
||||
|
||||
@@ -3,15 +3,14 @@ use crate::database::*;
|
||||
use mongodb::bson::{doc, from_document};
|
||||
use rauth::auth::Session;
|
||||
use rocket::http::Status;
|
||||
use rocket::outcome::try_outcome;
|
||||
use rocket::request::{self, FromRequest, Outcome, Request};
|
||||
|
||||
#[rocket::async_trait]
|
||||
impl<'a, 'r> FromRequest<'a, 'r> for User {
|
||||
impl<'r> FromRequest<'r> for User {
|
||||
type Error = rauth::util::Error;
|
||||
|
||||
async fn from_request(request: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
|
||||
let session: Session = try_outcome!(request.guard::<Session>().await);
|
||||
async fn from_request(request: &'r Request<'_>) -> request::Outcome<Self, Self::Error> {
|
||||
let session: Session = request.guard::<Session>().await.unwrap();
|
||||
|
||||
if let Ok(result) = get_collection("users")
|
||||
.find_one(
|
||||
|
||||
Reference in New Issue
Block a user