This commit is contained in:
Sofía Aritz 2024-10-14 21:12:40 +02:00
parent d3ec3ed422
commit 546e883a9c
Signed by: sofia
GPG key ID: 90B5116E3542B28F
3 changed files with 8 additions and 8 deletions

View file

@ -90,7 +90,7 @@ pub struct LocationEntry {
impl LocationEntry {
pub fn location_coordinates(&self) -> Option<LocationCoordinates> {
self.location_coordinates.as_ref().map(|v| serde_json::from_str(&v).unwrap())
self.location_coordinates.as_ref().map(|v| serde_json::from_str(v).unwrap())
}
}

View file

@ -1,7 +1,7 @@
use axum::{async_trait, extract::FromRequestParts, http::{header::AUTHORIZATION, request::Parts, StatusCode}};
use jsonwebtoken::Validation;
use serde::{Serialize, Deserialize};
use tracing::{warn, info};
use tracing::warn;
use crate::env;
@ -21,7 +21,7 @@ where
{
type Rejection = (StatusCode, &'static str);
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
if let Some(authorization) = parts.headers.get(AUTHORIZATION) {
if let Ok(authorization) = authorization.to_str() {
let token = authorization.replacen("Bearer ", "", 1);

View file

@ -8,14 +8,14 @@ use jsonwebtoken::Header;
use tracing::{error, info};
use serde::{Serialize, Deserialize};
use uuid::Uuid;
use crate::{database::models::User, database::list::List, env, http::extractors::auth::{ExtractUser, JwtUser}, AppState};
use crate::{database::models::User, env, http::extractors::auth::{ExtractUser, JwtUser}, AppState};
pub fn auth_router() -> Router<AppState> {
let router = Router::new()
.route("/auth/account", get(account))
.route("/auth/register", post(register));
router
Router::new()
.route("/auth/account", get(account))
.route("/auth/register", post(register))
}
async fn account(ExtractUser(jwt_user): ExtractUser, State(state): State<AppState>) -> Result<Json<User>, StatusCode> {