Skip to content

Commit

Permalink
Banjofox/refactor aardwolf models with clippy fixes (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
BanjoFox authored Jul 3, 2024
2 parents ef7d8d4 + fb14d8d commit 6acea76
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 18 deletions.
1 change: 0 additions & 1 deletion aardwolf-models/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ thiserror = "1.0"
url = "2.1"
dotenvy ="0.15"


[dependencies.uuid]
version = "1.3"
features = ["v4"]
Expand Down
2 changes: 1 addition & 1 deletion aardwolf-models/src/base_post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl NewBasePost {
posted_by: posted_by.id(),
icon: icon.map(|i| i.id()),
visibility,
activitypub_id: generate_id.post_id(&posted_by, &uuid),
activitypub_id: generate_id.post_id(posted_by, &uuid),
local_uuid: Some(uuid),
}
}
Expand Down
2 changes: 1 addition & 1 deletion aardwolf-models/src/sql_types/mime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl Serialize for Mime {
where
S: Serializer,
{
serializer.serialize_str(&self.to_string())
serializer.serialize_str(self.as_ref())
}
}

Expand Down
10 changes: 4 additions & 6 deletions aardwolf-models/src/user/email.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ impl UnverifiedEmail {
user: UnverifiedUser,
token: EmailVerificationToken,
) -> Result<(AuthenticatedUser, VerifyEmail), VerificationError> {
let res = self.verify(token).map(|verify_email| {


self.verify(token).map(|verify_email| {
(
AuthenticatedUser {
id: user.id,
Expand All @@ -199,11 +201,7 @@ impl UnverifiedEmail {
},
verify_email,
)
});

drop(user);

res
})
}

pub fn verify(self, token: EmailVerificationToken) -> Result<VerifyEmail, VerificationError> {
Expand Down
2 changes: 1 addition & 1 deletion aardwolf-models/src/user/email/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl VerifyEmail for HashedEmailToken {
&self,
email_verification_token: EmailVerificationToken,
) -> Result<(), VerificationError> {
verify(&email_verification_token.0, &self.0)
verify(email_verification_token.0, &self.0)
.map_err(|_| VerificationError::Process)
.and_then(|verified| {
if verified {
Expand Down
10 changes: 4 additions & 6 deletions aardwolf-models/src/user/local_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,15 @@ impl LocalAuth {
return Err(VerificationError::Process);
}

let res = self.password.verify(password).map(|_| AuthenticatedUser {


self.password.verify(password).map(|_| AuthenticatedUser {
id: user.id,
primary_email: user.primary_email,
primary_persona: user.primary_persona,
created_at: user.created_at,
updated_at: user.updated_at,
});

drop(user);

res
})
}
}

Expand Down
4 changes: 2 additions & 2 deletions aardwolf-models/src/user/local_auth/password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ impl fmt::Display for Password {

impl Verify for Password {
fn verify(&self, given_password: PlaintextPassword) -> Result<(), VerificationError> {
verify(&given_password.0, &self.0)
verify(given_password.0, &self.0)
.map_err(|e| {
error!("Error verifying password: {}", e);

Expand All @@ -256,7 +256,7 @@ impl Create for Password {
warn!("BUILT IN TEST MODE");

#[cfg(not(any(test, feature = "test")))]
let h = hash(&password.0, bcrypt::DEFAULT_COST);
let h = hash(password.0, bcrypt::DEFAULT_COST);
#[cfg(any(test, feature = "test"))]
let h = hash(&password.0, 4);

Expand Down

0 comments on commit 6acea76

Please sign in to comment.