From 27b904b3f5b2724729b7d553b77b7e6304f715bf Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Sun, 29 Aug 2021 19:07:36 +0200 Subject: [PATCH] Pleased the linters --- src/auth/jwt.rs | 2 +- src/auth/mod.rs | 12 ++---------- src/guards.rs | 6 +++--- src/routes/admin.rs | 4 ++-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/auth/jwt.rs b/src/auth/jwt.rs index 5c15d57..8767bb3 100644 --- a/src/auth/jwt.rs +++ b/src/auth/jwt.rs @@ -9,7 +9,7 @@ use sha2::Sha256; use crate::{ db::{ tokens::{NewRefreshToken, RefreshToken}, - users::{NewUser, User}, + users::User, }, errors::RbError, schema::{refresh_tokens::dsl as refresh_tokens, users::dsl as users}, diff --git a/src/auth/mod.rs b/src/auth/mod.rs index 838a080..b315e82 100644 --- a/src/auth/mod.rs +++ b/src/auth/mod.rs @@ -1,19 +1,11 @@ -use ::jwt::SignWithKey; use argon2::verify_encoded; -use chrono::Utc; use diesel::{insert_into, prelude::*, PgConnection}; -use hmac::{Hmac, NewMac}; use rand::{thread_rng, Rng}; -use serde::{Deserialize, Serialize}; -use sha2::Sha256; use crate::{ - db::{ - tokens::{NewRefreshToken, RefreshToken}, - users::{NewUser, User}, - }, + db::users::{NewUser, User}, errors::RbError, - schema::{refresh_tokens::dsl as refresh_tokens, users::dsl as users}, + schema::users::dsl as users, }; pub mod jwt; diff --git a/src/guards.rs b/src/guards.rs index 26cda21..55df193 100644 --- a/src/guards.rs +++ b/src/guards.rs @@ -39,10 +39,10 @@ impl<'r> FromRequest<'r> for Bearer<'r> } /// Verifies the provided JWT is valid. -pub struct JWT(Claims); +pub struct Jwt(Claims); #[rocket::async_trait] -impl<'r> FromRequest<'r> for JWT +impl<'r> FromRequest<'r> for Jwt { type Error = rb::errors::RbError; @@ -91,7 +91,7 @@ impl<'r> FromRequest<'r> for User async fn from_request(req: &'r Request<'_>) -> Outcome { - let claims = try_outcome!(req.guard::().await).0; + let claims = try_outcome!(req.guard::().await).0; // Verify key hasn't yet expired if chrono::Utc::now().timestamp() > claims.exp { diff --git a/src/routes/admin.rs b/src/routes/admin.rs index bd6f53f..9da75f5 100644 --- a/src/routes/admin.rs +++ b/src/routes/admin.rs @@ -10,13 +10,13 @@ pub fn routes() -> Vec } #[get("/users")] -async fn get_users(admin: Admin, conn: RbDbConn) -> rb::Result>> +async fn get_users(_admin: Admin, conn: RbDbConn) -> rb::Result>> { Ok(Json(conn.run(|c| db::users::all(c)).await?)) } #[post("/users", data = "")] -async fn create_user(admin: Admin, conn: RbDbConn, user: Json) -> rb::Result<()> +async fn create_user(_admin: Admin, conn: RbDbConn, user: Json) -> rb::Result<()> { Ok(conn .run(move |c| db::users::create(c, &user.into_inner()))