From 458afd3577a3ca13766539ebb6638991b947f7e3 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Sat, 18 May 2024 00:10:22 +0530 Subject: [PATCH] chore: lints --- .../application/services/login/command.rs | 17 ++++++++++++----- .../application/services/login/service.rs | 8 +++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/identity/application/services/login/command.rs b/src/identity/application/services/login/command.rs index 0b2540e..6440053 100644 --- a/src/identity/application/services/login/command.rs +++ b/src/identity/application/services/login/command.rs @@ -13,9 +13,12 @@ pub struct LoginCommand { } impl LoginCommand { - pub fn new(_username: String, supplied_password: String, actual_password_hash: &str) -> IdentityCommandResult { - let success = - argon2_creds::Config::verify(actual_password_hash, &supplied_password)?; + pub fn new( + _username: String, + supplied_password: String, + actual_password_hash: &str, + ) -> IdentityCommandResult { + let success = argon2_creds::Config::verify(actual_password_hash, &supplied_password)?; Ok(Self { success }) } } @@ -30,10 +33,14 @@ mod tests { let password = "adsfasdfasd"; let hashed_password = config.password(password).unwrap(); assert!( - LoginCommand::new("realaravinth".into(), password.into(), &hashed_password,).unwrap().success + LoginCommand::new("realaravinth".into(), password.into(), &hashed_password,) + .unwrap() + .success ); assert!( - !LoginCommand::new("realaravinth".into(), "password".into(), &hashed_password,).unwrap().success + !LoginCommand::new("realaravinth".into(), "password".into(), &hashed_password,) + .unwrap() + .success ); } } diff --git a/src/identity/application/services/login/service.rs b/src/identity/application/services/login/service.rs index 091183a..2b2187a 100644 --- a/src/identity/application/services/login/service.rs +++ b/src/identity/application/services/login/service.rs @@ -12,7 +12,7 @@ impl LoginUseCase for LoginService { &self, cmd: command::LoginCommand, //) -> errors::ProcessAuthorizationServiceResult; - ) -> events::LoginEvent { + ) -> events::LoginEvent { events::LoginEvent::new(cmd.success().to_owned()) } } @@ -32,7 +32,8 @@ mod tests { { let cmd = - command::LoginCommand::new(username.into(), password.into(), &hashed_password).unwrap(); + command::LoginCommand::new(username.into(), password.into(), &hashed_password) + .unwrap(); let res = s.login(cmd.clone()).await; assert_eq!(res.success(), cmd.success()); } @@ -40,7 +41,8 @@ mod tests { { // success=false: let cmd = - command::LoginCommand::new(username.into(), "asdfasdf".into(), &hashed_password).unwrap(); + command::LoginCommand::new(username.into(), "asdfasdf".into(), &hashed_password) + .unwrap(); let res = s.login(cmd.clone()).await; assert_eq!(res.success(), cmd.success()); }