backend: fix imports
This commit is contained in:
parent
df6502a1c2
commit
44e61805b0
2 changed files with 3 additions and 29 deletions
|
@ -1,14 +1,8 @@
|
|||
use core::fmt;
|
||||
use std::{pin::Pin, time::SystemTime};
|
||||
|
||||
use actix_web::{
|
||||
error::ErrorUnauthorized,
|
||||
http::{header, StatusCode},
|
||||
web, Error, FromRequest, HttpRequest, HttpResponse, ResponseError,
|
||||
};
|
||||
use actix_web::{error::ErrorUnauthorized, http::header, web, Error, FromRequest, HttpRequest};
|
||||
use futures::Future;
|
||||
use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation};
|
||||
use migration::token;
|
||||
use jsonwebtoken::{DecodingKey, EncodingKey, Header};
|
||||
use sea_orm::EntityTrait;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
@ -46,7 +40,7 @@ impl AuthedUser {
|
|||
let header = req
|
||||
.headers()
|
||||
.get(header::AUTHORIZATION)
|
||||
.ok_or(AuthorizationError)?;
|
||||
.ok_or(ErrorUnauthorized("Unauthorized"))?;
|
||||
|
||||
if header.len() < 8 {
|
||||
return Err(ErrorUnauthorized("Unauthorized"));
|
||||
|
@ -102,22 +96,3 @@ impl FromRequest for AuthedUser {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct AuthorizationError;
|
||||
|
||||
impl fmt::Display for AuthorizationError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(&self.status_code(), f)
|
||||
}
|
||||
}
|
||||
|
||||
impl ResponseError for AuthorizationError {
|
||||
fn status_code(&self) -> actix_web::http::StatusCode {
|
||||
StatusCode::UNAUTHORIZED
|
||||
}
|
||||
|
||||
fn error_response(&self) -> actix_web::HttpResponse<actix_web::body::BoxBody> {
|
||||
HttpResponse::build(self.status_code()).finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use actix_web::{web, App, HttpServer};
|
||||
use jsonwebtoken::EncodingKey;
|
||||
use migration::MigratorTrait;
|
||||
use sea_orm::{Database, DatabaseConnection};
|
||||
use std::env;
|
||||
|
|
Loading…
Add table
Reference in a new issue