forked from Roflin/gamenight
Fixes some Clippy remarks.
This commit is contained in:
@@ -13,7 +13,7 @@ use crate::util::GetConnection;
|
||||
|
||||
impl GamenightPost {
|
||||
pub fn into_with_user(&self, user: User) -> Result<schema::gamenight::Gamenight, ParseError> {
|
||||
return Ok(schema::gamenight::Gamenight {
|
||||
Ok(schema::gamenight::Gamenight {
|
||||
datetime: DateTime::parse_from_rfc3339(&self.datetime)?.with_timezone(&chrono::Utc),
|
||||
id: Uuid::new_v4(),
|
||||
name: self.name.clone(),
|
||||
@@ -22,9 +22,9 @@ impl GamenightPost {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<Uuid> for GamenightGet {
|
||||
fn into(self) -> Uuid {
|
||||
Uuid::parse_str(self.id.as_str()).unwrap()
|
||||
impl From<GamenightGet> for Uuid {
|
||||
fn from(value: GamenightGet) -> Self {
|
||||
Uuid::parse_str(value.id.as_str()).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,21 +11,21 @@ use crate::util::GetConnection;
|
||||
use crate::schema::{self};
|
||||
use serde_json;
|
||||
|
||||
impl Into<schema::user::LoginUser> for Login {
|
||||
fn into(self) -> schema::user::LoginUser {
|
||||
impl From<Login> for schema::user::LoginUser {
|
||||
fn from(val: Login) -> Self {
|
||||
schema::user::LoginUser {
|
||||
username: self.username,
|
||||
password: self.password
|
||||
username: val.username,
|
||||
password: val.password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<schema::user::Register> for Register {
|
||||
fn into(self) -> schema::user::Register {
|
||||
impl From<Register> for schema::user::Register {
|
||||
fn from(val: Register) -> Self {
|
||||
schema::user::Register {
|
||||
email: self.email,
|
||||
username: self.username,
|
||||
password: self.password
|
||||
email: val.email,
|
||||
username: val.username,
|
||||
password: val.password
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ pub async fn register(pool: web::Data<DbPool>, register_data: web::Json<Register
|
||||
Ok(())
|
||||
}).await??;
|
||||
|
||||
return Ok(HttpResponse::Ok())
|
||||
Ok(HttpResponse::Ok())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ pub fn login(conn: &mut PgConnection, user: LoginUser) -> Result<Option<User>, D
|
||||
let parsed_hash = PasswordHash::new(&pwd)?;
|
||||
|
||||
if Argon2::default()
|
||||
.verify_password(&user.password.as_bytes(), &parsed_hash)
|
||||
.verify_password(user.password.as_bytes(), &parsed_hash)
|
||||
.is_ok()
|
||||
{
|
||||
Ok(Some(users::table.find(id).first(conn)?))
|
||||
@@ -135,7 +135,7 @@ pub fn register(conn: &mut PgConnection, register: Register) -> Result<(), Datab
|
||||
|
||||
diesel::insert_into(users::table)
|
||||
.values(User {
|
||||
id: id.clone(),
|
||||
id,
|
||||
username: register.username,
|
||||
email: register.email,
|
||||
role: Role::User,
|
||||
|
||||
Reference in New Issue
Block a user