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 std::{pin::Pin, time::SystemTime};
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{error::ErrorUnauthorized, http::header, web, Error, FromRequest, HttpRequest};
|
||||||
error::ErrorUnauthorized,
|
|
||||||
http::{header, StatusCode},
|
|
||||||
web, Error, FromRequest, HttpRequest, HttpResponse, ResponseError,
|
|
||||||
};
|
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation};
|
use jsonwebtoken::{DecodingKey, EncodingKey, Header};
|
||||||
use migration::token;
|
|
||||||
use sea_orm::EntityTrait;
|
use sea_orm::EntityTrait;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
@ -46,7 +40,7 @@ impl AuthedUser {
|
||||||
let header = req
|
let header = req
|
||||||
.headers()
|
.headers()
|
||||||
.get(header::AUTHORIZATION)
|
.get(header::AUTHORIZATION)
|
||||||
.ok_or(AuthorizationError)?;
|
.ok_or(ErrorUnauthorized("Unauthorized"))?;
|
||||||
|
|
||||||
if header.len() < 8 {
|
if header.len() < 8 {
|
||||||
return Err(ErrorUnauthorized("Unauthorized"));
|
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 actix_web::{web, App, HttpServer};
|
||||||
use jsonwebtoken::EncodingKey;
|
|
||||||
use migration::MigratorTrait;
|
use migration::MigratorTrait;
|
||||||
use sea_orm::{Database, DatabaseConnection};
|
use sea_orm::{Database, DatabaseConnection};
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
Loading…
Add table
Reference in a new issue