Pleased the linters

develop
Jef Roosens 2021-08-29 19:07:36 +02:00
parent 6858e9da62
commit 27b904b3f5
Signed by untrusted user: Jef Roosens
GPG Key ID: 955C0660072F691F
4 changed files with 8 additions and 16 deletions

View File

@ -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},

View File

@ -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;

View File

@ -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<Self, Self::Error>
{
let claims = try_outcome!(req.guard::<JWT>().await).0;
let claims = try_outcome!(req.guard::<Jwt>().await).0;
// Verify key hasn't yet expired
if chrono::Utc::now().timestamp() > claims.exp {

View File

@ -10,13 +10,13 @@ pub fn routes() -> Vec<rocket::Route>
}
#[get("/users")]
async fn get_users(admin: Admin, conn: RbDbConn) -> rb::Result<Json<Vec<db::User>>>
async fn get_users(_admin: Admin, conn: RbDbConn) -> rb::Result<Json<Vec<db::User>>>
{
Ok(Json(conn.run(|c| db::users::all(c)).await?))
}
#[post("/users", data = "<user>")]
async fn create_user(admin: Admin, conn: RbDbConn, user: Json<db::NewUser>) -> rb::Result<()>
async fn create_user(_admin: Admin, conn: RbDbConn, user: Json<db::NewUser>) -> rb::Result<()>
{
Ok(conn
.run(move |c| db::users::create(c, &user.into_inner()))