style: cargo clippy && format
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
This commit is contained in:
parent
860fa7a66e
commit
8605b81e7b
26 changed files with 274 additions and 178 deletions
|
@ -1,10 +1,17 @@
|
|||
use actix_web::{HttpRequest, HttpResponse, post, web};
|
||||
use argon2::{PasswordHash, PasswordVerifier};
|
||||
use diesel::{delete, ExpressionMethods, QueryDsl};
|
||||
use diesel::{ExpressionMethods, QueryDsl, delete};
|
||||
use diesel_async::RunQueryDsl;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{api::v1::auth::check_access_token, error::Error, schema::users::dsl as udsl, schema::refresh_tokens::{self, dsl as rdsl}, utils::get_auth_header, Data};
|
||||
use crate::{
|
||||
Data,
|
||||
api::v1::auth::check_access_token,
|
||||
error::Error,
|
||||
schema::refresh_tokens::{self, dsl as rdsl},
|
||||
schema::users::dsl as udsl,
|
||||
utils::get_auth_header,
|
||||
};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct RevokeRequest {
|
||||
|
@ -33,14 +40,17 @@ pub async fn res(
|
|||
.get_result(&mut conn)
|
||||
.await?;
|
||||
|
||||
let hashed_password = PasswordHash::new(&database_password).map_err(|e| Error::PasswordHashError(e.to_string()))?;
|
||||
let hashed_password = PasswordHash::new(&database_password)
|
||||
.map_err(|e| Error::PasswordHashError(e.to_string()))?;
|
||||
|
||||
if data
|
||||
.argon2
|
||||
.verify_password(revoke_request.password.as_bytes(), &hashed_password)
|
||||
.is_err()
|
||||
{
|
||||
return Err(Error::Unauthorized("Wrong username or password".to_string()));
|
||||
return Err(Error::Unauthorized(
|
||||
"Wrong username or password".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
delete(refresh_tokens::table)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue