Simplify user update call syntax
This commit is contained in:
parent
b10c48d080
commit
0c35400e64
@ -56,11 +56,8 @@ pub struct AddSuccessful2FALogin(pub UserID, pub IpAddr);
|
||||
#[rtype(result = "bool")]
|
||||
pub struct Clear2FALoginHistory(pub UserID);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UpdateUserResult(pub bool);
|
||||
|
||||
#[derive(Message)]
|
||||
#[rtype(UpdateUserResult)]
|
||||
#[rtype(result = "bool")]
|
||||
pub struct UpdateUserRequest(pub User);
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -157,16 +154,16 @@ impl Handler<GetAllUsersRequest> for UsersActor {
|
||||
}
|
||||
|
||||
impl Handler<UpdateUserRequest> for UsersActor {
|
||||
type Result = MessageResult<UpdateUserRequest>;
|
||||
type Result = <UpdateUserRequest as actix::Message>::Result;
|
||||
|
||||
fn handle(&mut self, msg: UpdateUserRequest, _ctx: &mut Self::Context) -> Self::Result {
|
||||
MessageResult(UpdateUserResult(match self.manager.update_or_push(msg.0) {
|
||||
match self.manager.update_or_push(msg.0) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
log::error!("Failed to update user information! {:?}", e);
|
||||
false
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,8 +132,7 @@ pub async fn users_route(
|
||||
let res = users
|
||||
.send(users_actor::UpdateUserRequest(user.clone()))
|
||||
.await
|
||||
.unwrap()
|
||||
.0;
|
||||
.unwrap();
|
||||
|
||||
if !res {
|
||||
danger = Some(
|
||||
|
@ -61,8 +61,7 @@ pub async fn save_totp_factor(
|
||||
let res = users
|
||||
.send(users_actor::UpdateUserRequest(user))
|
||||
.await
|
||||
.unwrap()
|
||||
.0;
|
||||
.unwrap();
|
||||
|
||||
if !res {
|
||||
HttpResponse::InternalServerError().body("Failed to update user information!")
|
||||
@ -110,8 +109,7 @@ pub async fn save_webauthn_factor(
|
||||
let res = users
|
||||
.send(users_actor::UpdateUserRequest(user))
|
||||
.await
|
||||
.unwrap()
|
||||
.0;
|
||||
.unwrap();
|
||||
|
||||
if !res {
|
||||
HttpResponse::InternalServerError().body("Failed to update user information!")
|
||||
@ -137,8 +135,7 @@ pub async fn delete_factor(
|
||||
let res = users
|
||||
.send(users_actor::UpdateUserRequest(user))
|
||||
.await
|
||||
.unwrap()
|
||||
.0;
|
||||
.unwrap();
|
||||
|
||||
if !res {
|
||||
HttpResponse::InternalServerError().body("Failed to update user information!")
|
||||
|
Loading…
Reference in New Issue
Block a user