Simplify password change call syntax

This commit is contained in:
2022-11-19 16:41:39 +01:00
parent d06c0352fc
commit b10c48d080
3 changed files with 8 additions and 15 deletions

View File

@ -41,16 +41,13 @@ pub struct GetAllUsersRequest;
pub struct GetAllUsersResult(pub Vec<User>);
#[derive(Message)]
#[rtype(ChangePasswordResult)]
#[rtype(result = "bool")]
pub struct ChangePasswordRequest {
pub user_id: UserID,
pub new_password: String,
pub temporary: bool,
}
#[derive(Debug)]
pub struct ChangePasswordResult(pub bool);
#[derive(Message)]
#[rtype(result = "bool")]
pub struct AddSuccessful2FALogin(pub UserID, pub IpAddr);
@ -109,14 +106,11 @@ impl Handler<LoginRequest> for UsersActor {
}
impl Handler<ChangePasswordRequest> for UsersActor {
type Result = MessageResult<ChangePasswordRequest>;
type Result = <ChangePasswordRequest as actix::Message>::Result;
fn handle(&mut self, msg: ChangePasswordRequest, _ctx: &mut Self::Context) -> Self::Result {
MessageResult(ChangePasswordResult(self.manager.change_user_password(
&msg.user_id,
&msg.new_password,
msg.temporary,
)))
self.manager
.change_user_password(&msg.user_id, &msg.new_password, msg.temporary)
}
}